-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
72 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package constants | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestRegisterCodeTable(t *testing.T) { | ||
const ( | ||
c1000000 = CodeType(1000000) | ||
c1000001 = CodeType(1000001) | ||
) | ||
RegisterCodeTable(LanguageEnglish, map[ICodeType]string{c1000000: "1000000", c1000001: "1000001"}) | ||
assert.Equal(t, "1000000", c1000000.String()) | ||
assert.Equal(t, "1000001", c1000001.String()) | ||
} | ||
|
||
func TestRegisterCodeSingle(t *testing.T) { | ||
const ( | ||
c1000000 = CodeType(1000000) | ||
c1000001 = CodeType(1000001) | ||
) | ||
RegisterCodeSingle(LanguageEnglish, c1000000, "1000000") | ||
RegisterCodeSingle(LanguageEnglish, c1000001, "1000001") | ||
assert.Equal(t, "1000000", c1000000.String()) | ||
assert.Equal(t, "1000001", c1000001.String()) | ||
} |
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,19 @@ | ||
package constants | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestString(t *testing.T) { | ||
for lang, msgMap := range initErrorCodeMsgMap { | ||
RegisterCodeTable(lang, msgMap) | ||
} | ||
assert.Equal(t, "SUCCESS", ErrNone.String(LanguageEnglish.String())) | ||
assert.Equal(t, "成功", ErrNone.String(LanguageChinesePRC.String())) | ||
} | ||
|
||
func TestInt(t *testing.T) { | ||
assert.Equal(t, 0, ErrNone.Int()) | ||
} |
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,23 @@ | ||
package constants | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestI18NString(t *testing.T) { | ||
assert.Equal(t, "en", LanguageEnglish.String()) | ||
} | ||
|
||
func TestI18NToLowerCase(t *testing.T) { | ||
assert.Equal(t, "en", LanguageEnglish.ToLowerCase()) | ||
} | ||
|
||
func TestI18NToUpperCase(t *testing.T) { | ||
assert.Equal(t, "EN", LanguageEnglish.ToUpperCase()) | ||
} | ||
|
||
func TestI18NExist(t *testing.T) { | ||
assert.Equal(t, true, LanguageEnglish.Exist()) | ||
} |
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