-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: possible inf loop * feat: messaging and fmts * feat: messaging and fmts
- Loading branch information
1 parent
371f03d
commit 16a783e
Showing
5 changed files
with
99 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package pkg | ||
|
||
import ( | ||
"strconv" | ||
"testing" | ||
) | ||
|
||
func TestNumberToK(t *testing.T) { | ||
tests := []struct { | ||
input int | ||
expected string | ||
}{ | ||
{999, "999"}, // Less than 1000 | ||
{1000, "1.0K"}, // Exactly 1000 | ||
{1500, "1.5K"}, // Simple thousands | ||
{25000, "25.0K"}, // Larger thousands | ||
{1000000, "1000.0K"}, // Very large numbers | ||
{0, "0"}, // Edge case: zero | ||
{-500, "-500"}, // Negative numbers (no conversion) | ||
{-1500, "-1500"}, // Negative thousand (not supported) | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run( | ||
"Input: "+strconv.Itoa(test.input), | ||
func(t *testing.T) { | ||
result := NumberToK(test.input) | ||
if result != test.expected { | ||
t.Errorf("ConvertToK(%d) = %s; expected %s", test.input, result, test.expected) | ||
} | ||
}, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters