예제 #1
0
파일: wrap_test.go 프로젝트: mabetle/mcell
func TestGetCellValue(t *testing.T) {
	mtest.RegTest(t)
	fn := "testdata/demo.xlsx"
	in := GetCellValue(fn, "Sheet1", "A1", "")
	//println(in)
	mtest.AssertEqual(in, "ID")
}
예제 #2
0
func TestStringValidator(t *testing.T) {
	mtest.RegTest(t)

	//test email
	mtest.Equal(String("*****@*****.**").IsEmail(), true, "[email protected] is a email")
	mtest.Equal(String("demo.com").IsEmail(), false, "demo.com is not a email")

	//test english
	mtest.Equal(String("你好").IsChinese(), true, "你好 is no Engllish")
	mtest.Equal(String("Hello").IsEnglish(), true, "Hello is English")

	//test chinese
	mtest.Equal(String("你好").IsChinese(), true, "你好 is Chinese")
	mtest.Equal(String("Hello").IsEnglish(), true, "Hello is not Chinese")

	//test Idcard
	mtest.Equal(String("110110198801018721").IsIdCardNo(), true, "Is a IdCard number")
	mtest.Equal(String("hello").IsIdCardNo(), false, "Not a IdCard number")

	//test Phone number
	mtest.Equal(String("13900910001").IsPhoneNumber(), true, "Is a phone number")
	mtest.Equal(String("139sss00910001").IsPhoneNumber(), false, "Not a phone number")

	mtest.Equal(String("asdf").IsNumber(), false, "not a number")
	mtest.Equal(String("1012,312.12").IsNumber(), true, "not a number")

}
예제 #3
0
파일: valid_test.go 프로젝트: mabetle/mcore
func TestXXX(t *testing.T) {
	m := Model{}
	m.Id = "1"
	m.Email = "*****@*****.**"
	mtest.RegTest(t)
	mtest.AssertEqual(true, true)
	PrintValidate(m)
}
예제 #4
0
func TestArgsA(t *testing.T) {
	mtest.RegTest(t)

	s := "-d -f=demo.txt Hello Demo"
	a := NewArgsFromString(s)

	mtest.Equal(4, a.NArgs())
}
예제 #5
0
func TestStrBuffer(t *testing.T) {
	mtest.RegTest(t)

	sb := NewStringBuffer()
	sb.Append("Hello")

	mtest.Equal("Hello", sb.String())
}
예제 #6
0
func TestSepEnd(t *testing.T) {
	mtest.RegTest(t)
	mtest.AssertEqual("def", String("/aaa/abc.def").SepEnd("."))
	mtest.AssertEqual("def", String("/aaa/abc/def").SepEnd("/"))
	mtest.AssertEqual("def", String("/aaa/abc\\def").SepEnd("\\"))
	mtest.AssertEqual("def", String("/aaa/abc@def").SepEnd("@"))
	mtest.AssertEqual("", String("/aaa/abc@def").SepEnd("#"))
}
예제 #7
0
func TestKeyValueConfig(t *testing.T) {
	mtest.RegTest(t)
	c := NewConfig(&TestLoader{})

	mtest.AssertEqual(true, c.IsContain("a"))
	mtest.AssertEqual("a", c.GetString("a"))
	mtest.AssertEqual(false, c.GetBool("b"))
	mtest.AssertEqual(c.GetInt("c"), 5)
}
예제 #8
0
func TestReadConfigFromString(t *testing.T) {
	mtest.RegTest(t)

	s := `
hello=hello from string
name=demo
	`
	c, err := ReadConfigFromString(s)
	mcore.CheckError(err)

	v, _ := c.String("", "hello")
	mtest.Equal("hello from string", v)
}
예제 #9
0
파일: round_test.go 프로젝트: mabetle/mcore
func TestRound(t *testing.T) {
	mtest.RegTest(t)
	mtest.AssertTrue(RoundInt(3.14159) == 3)
	mtest.AssertTrue(RoundInt(3.54159) == 4)

	mtest.AssertTrue(Round(3.54159, 1) == 3.5)
	mtest.AssertTrue(Round(3.54159, 2) == 3.54)
	mtest.AssertTrue(Round(3.54159, 3) == 3.542)
	mtest.AssertTrue(Round(13.54159, -1) == 10)

	mtest.AssertTrue(RoundUp(3.54159, 1) == 3.6)
	mtest.AssertTrue(RoundUp(3.54159, 2) == 3.55)
	mtest.AssertTrue(RoundUp(3.54159, 3) == 3.542)
	mtest.AssertTrue(RoundUp(13.54159, -1) == 20)

	mtest.AssertTrue(RoundDown(3.54159, 1) == 3.5)
	mtest.AssertTrue(RoundDown(3.54159, 2) == 3.54)
	mtest.AssertTrue(RoundDown(3.54159, 3) == 3.541)
	mtest.AssertTrue(RoundDown(13.54159, -1) == 10)

}
예제 #10
0
파일: wmap_test.go 프로젝트: mabetle/mcore
func TestIsMapHasKey(t *testing.T) {
	mtest.RegTest(t)
	InitMap()
	mtest.AssertTrue(IsMapHasKey(m, "a"))
	mtest.AssertTrue(!IsMapHasKey(m, "none"))
}
예제 #11
0
func TestTrimEndIndex(t *testing.T) {
	mtest.RegTest(t)

	mtest.AssertEqual(String("/a/b/c.txt").TrimEndIndex("/"), "/a/b")
}
예제 #12
0
func TestGetFields(t *testing.T) {
	mtest.RegTest(t)
	mtest.AssertTrue(true)
}
예제 #13
0
func TestIsHasMethod(t *testing.T) {
	mtest.RegTest(t)
	mtest.AssertTrue(IsHasMethod(demo, "Hello"))
	mtest.AssertFalse(IsHasMethod(demo, "None"))
}
예제 #14
0
func TestUpper(t *testing.T) {
	mtest.RegTest(t)
}
예제 #15
0
파일: plain_test.go 프로젝트: mabetle/mcore
func TestPlainEncode(t *testing.T) {
	mtest.RegTest(t)
	mtest.AssertEqual(plain.Encode("demo"), "demo")
}
예제 #16
0
파일: util_test.go 프로젝트: mabetle/mcell
func TestGetLetterIndex(t *testing.T) {
	mtest.RegTest(t)
	mtest.AssertEqual(GetLetterIndex("a"), 0)
	mtest.AssertEqual(GetLetterIndex("aa"), 26)
	mtest.AssertEqual(GetLetterIndex("zz"), 25+26*26)
}
예제 #17
0
// DemoDemo  > demo_demo
func TestToTableName(t *testing.T) {
	mtest.RegTest(t)
	mtest.AssertEqual("demo_demo", ToTableName("DemoDemo"))
}
예제 #18
0
파일: path_test.go 프로젝트: mabetle/mcore
func TestGetLocation(t *testing.T) {
	mtest.RegTest(t)
	mtest.AssertEqual("abc/def.go", GetLocation("abc", "def.go"))
	mtest.AssertEqual("abc/def.go", GetLocation("abc/", "def.go"))
}
예제 #19
0
파일: util_test.go 프로젝트: mabetle/mcell
func TestGetRowColIndex(t *testing.T) {
	mtest.RegTest(t)
	row, col := GetRowColIndex("AA23")
	mtest.AssertEqual(col, 26, "AA23 row should be 26")
	mtest.AssertEqual(row, 22, "AA23 col should be 22")
}
예제 #20
0
func TestWriteLines(t *testing.T) {
	mtest.RegTest(t)
	lines := []string{"line 1", "line 2", "line 3"}
	WriteLines(os.Stdout, lines)
}
예제 #21
0
func TestWriteStrings(t *testing.T) {
	mtest.RegTest(t)
	WriteStrings(os.Stdout, "hello,", "demo write strings.")
}
예제 #22
0
func TestWriteText(t *testing.T) {
	mtest.RegTest(t)
	WriteText(os.Stdout, "test write to os.Stdout\n")
	WriteText(os.Stderr, "test write to os.Stderr\n")
}
예제 #23
0
func TestTrimBeginIndex(t *testing.T) {
	mtest.RegTest(t)

	mtest.AssertEqual(String("a/b/c.txt").TrimBeginIndex("/"), "b/c.txt")
}
예제 #24
0
func TestAppConf(t *testing.T) {
	mtest.RegTest(t)
	mtest.AssertEqual(false, NewDefaultAppConf("none").IsExist())
	mtest.AssertEqual(dbcConf.GetVendorName(), "Mabetle")
}
예제 #25
0
func TestIsContain(t *testing.T) {
	mtest.RegTest(t)
	mtest.AssertEqual(true, skv.IsContain("a"))
	mtest.AssertEqual(true, skv.GetBool("c"))
}
예제 #26
0
func TestToCamel(t *testing.T) {
	mtest.RegTest(t)
	mtest.AssertEqual("DemoDemo", ToCamel("demo_demo"))
}