當前位置: 首頁>>代碼示例>>Golang>>正文


Golang v1.C類代碼示例

本文整理匯總了Golang中pkg/re/check/v1.C的典型用法代碼示例。如果您正苦於以下問題:Golang C類的具體用法?Golang C怎麽用?Golang C使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了C類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestParsing

func (s *KNFSuite) TestParsing(c *check.C) {
	err := Global(s.ConfigPath)

	c.Assert(err, check.IsNil)

	_, err = Reload()

	c.Assert(err, check.IsNil)
}
開發者ID:essentialkaos,項目名稱:ek,代碼行數:9,代碼來源:knf_test.go

示例2: TestComments

func (s *KNFSuite) TestComments(c *check.C) {
	var err error

	err = Global(s.ConfigPath)

	c.Assert(global, check.NotNil)
	c.Assert(err, check.IsNil)

	c.Assert(GetI("comment:test1"), check.Equals, 100)
	c.Assert(GetI("comment:test2"), check.Not(check.Equals), 100)
	c.Assert(HasProp("comment:test2"), check.Equals, false)
}
開發者ID:essentialkaos,項目名稱:ek,代碼行數:12,代碼來源:knf_test.go

示例3: SetUpSuite

func (s *KNFSuite) SetUpSuite(c *check.C) {
	tmpdir := c.MkDir()

	s.ConfigPath = tmpdir + "/" + _CONFIG_FILE_NAME
	s.EmptyConfigPath = tmpdir + "/" + _CONFIG_EMPTY_FILE_NAME
	s.MalformedConfigPath = tmpdir + "/" + _CONFIG_MALFORMED_FILE_NAME

	err := ioutil.WriteFile(s.ConfigPath, []byte(_CONFIG_DATA), 0644)

	if err != nil {
		c.Fatal(err.Error())
	}

	err = ioutil.WriteFile(s.EmptyConfigPath, []byte(""), 0644)

	if err != nil {
		c.Fatal(err.Error())
	}

	err = ioutil.WriteFile(s.MalformedConfigPath, []byte(_CONFIG_MALF_DATA), 0644)

	if err != nil {
		c.Fatal(err.Error())
	}
}
開發者ID:essentialkaos,項目名稱:ek,代碼行數:25,代碼來源:knf_test.go

示例4: TestFileMode

func (s *KNFSuite) TestFileMode(c *check.C) {
	var err error

	err = Global(s.ConfigPath)

	c.Assert(global, check.NotNil)
	c.Assert(err, check.IsNil)

	c.Assert(GetM("file-mode:test1"), check.Equals, os.FileMode(0644))
	c.Assert(GetM("file-mode:test2"), check.Equals, os.FileMode(0644))
	c.Assert(GetM("file-mode:test3"), check.Equals, os.FileMode(0))
	c.Assert(GetM("file-mode:test4"), check.Equals, os.FileMode(0))
	c.Assert(GetM("file-mode:test5"), check.Equals, os.FileMode(0))
}
開發者ID:essentialkaos,項目名稱:ek,代碼行數:14,代碼來源:knf_test.go

示例5: TestInfo

func (s *SSLLabsSuite) TestInfo(c *check.C) {
	api, err := NewAPI("SSLScanTester", "4.0.0")

	c.Assert(api, check.NotNil)
	c.Assert(err, check.IsNil)

	c.Assert(api.Info.EngineVersion, check.Equals, "1.24.4")
	c.Assert(api.Info.CriteriaVersion, check.Equals, "2009l")
}
開發者ID:essentialkaos,項目名稱:sslscan,代碼行數:9,代碼來源:sslscan_test.go

示例6: TestFormating

func (s *KNFSuite) TestFormating(c *check.C) {
	var err error

	err = Global(s.ConfigPath)

	c.Assert(global, check.NotNil)
	c.Assert(err, check.IsNil)

	c.Assert(GetI("formating:test1"), check.Equals, 1)
	c.Assert(GetI("formating:test2"), check.Equals, 2)
	c.Assert(GetI("formating:test3"), check.Equals, 3)
}
開發者ID:essentialkaos,項目名稱:ek,代碼行數:12,代碼來源:knf_test.go

示例7: TestProps

func (s *KNFSuite) TestProps(c *check.C) {
	var err error

	err = Global(s.ConfigPath)

	c.Assert(global, check.NotNil)
	c.Assert(err, check.IsNil)

	props := Props("file-mode")

	c.Assert(props, check.HasLen, 5)
	c.Assert(
		props,
		check.DeepEquals,
		[]string{"test1", "test2", "test3", "test4", "test5"},
	)
}
開發者ID:essentialkaos,項目名稱:ek,代碼行數:17,代碼來源:knf_test.go

示例8: TestSections

func (s *KNFSuite) TestSections(c *check.C) {
	var err error

	err = Global(s.ConfigPath)

	c.Assert(global, check.NotNil)
	c.Assert(err, check.IsNil)

	sections := Sections()

	c.Assert(sections, check.HasLen, 8)
	c.Assert(
		sections,
		check.DeepEquals,
		[]string{"formating", "string", "boolean", "integer", "file-mode", "comment", "macro", "k"},
	)
}
開發者ID:essentialkaos,項目名稱:ek,代碼行數:17,代碼來源:knf_test.go

示例9: TestNil

func (s *KNFSuite) TestNil(c *check.C) {
	var nilConf *Config

	c.Assert(nilConf.GetS("formating:test1"), check.Equals, "")
	c.Assert(nilConf.GetI("formating:test1"), check.Equals, 0)
	c.Assert(nilConf.GetF("formating:test1"), check.Equals, 0.0)
	c.Assert(nilConf.GetB("formating:test1"), check.Equals, false)
	c.Assert(nilConf.GetM("formating:test1"), check.Equals, os.FileMode(0))
	c.Assert(nilConf.HasSection("formating"), check.Equals, false)
	c.Assert(nilConf.HasProp("formating:test1"), check.Equals, false)
	c.Assert(nilConf.Sections(), check.HasLen, 0)
	c.Assert(nilConf.Props("formating"), check.HasLen, 0)

	_, err := nilConf.Reload()

	c.Assert(err, check.NotNil)
	c.Assert(err.Error(), check.Equals, "Config is nil")

	errs := nilConf.Validate([]*Validator{})

	c.Assert(errs, check.Not(check.HasLen), 0)
	c.Assert(errs[0].Error(), check.Equals, "Config is nil")
}
開發者ID:essentialkaos,項目名稱:ek,代碼行數:23,代碼來源:knf_test.go

示例10: TestMacro

func (s *KNFSuite) TestMacro(c *check.C) {
	var err error

	err = Global(s.ConfigPath)

	c.Assert(global, check.NotNil)
	c.Assert(err, check.IsNil)

	c.Assert(GetS("macro:test1"), check.Equals, "100")
	c.Assert(GetI("macro:test1"), check.Equals, 100)
	c.Assert(GetS("macro:test2"), check.Equals, "100.50")
	c.Assert(GetS("macro:test3"), check.Equals, "Value is 100.50")
	c.Assert(GetS("macro:test4"), check.Equals, "\"Value is 100.50\"")
	c.Assert(GetS("macro:test5"), check.Equals, "{ABC}")
	c.Assert(GetS("macro:test6"), check.Equals, "{}")
}
開發者ID:essentialkaos,項目名稱:ek,代碼行數:16,代碼來源:knf_test.go

示例11: TestProperPath

func (s *FSSuite) TestProperPath(c *check.C) {
	tmpFile := c.MkDir() + "/test.txt"

	os.OpenFile(tmpFile, os.O_CREATE, 0644)

	paths := []string{"/etc/sudoers", "/etc/passwd", tmpFile}

	c.Assert(ProperPath("DR", paths), check.Equals, "")
	c.Assert(ProperPath("FR", paths), check.Equals, "/etc/passwd")
	c.Assert(ProperPath("FRW", paths), check.Equals, tmpFile)
	c.Assert(ProperPath("FRWS", paths), check.Equals, "")
	c.Assert(ProperPath("F", paths), check.Equals, "/etc/sudoers")

	os.Remove(tmpFile)
}
開發者ID:essentialkaos,項目名稱:ek,代碼行數:15,代碼來源:fs_test.go

示例12: TestWalker

func (s *FSSuite) TestWalker(c *check.C) {
	tmpDir := c.MkDir()

	os.Chdir(tmpDir)

	tmpDir, _ = os.Getwd()

	os.MkdirAll(tmpDir+"/dir1/dir2/dir3/dir4", 0755)
	os.Chdir(tmpDir)

	c.Assert(Current(), check.Equals, tmpDir)
	c.Assert(Pop(), check.Equals, tmpDir)

	dirStack = nil

	c.Assert(Push("dir1"), check.Equals, tmpDir+"/dir1")
	c.Assert(Push("dir9"), check.Equals, "")
	c.Assert(Push("dir2/dir3"), check.Equals, tmpDir+"/dir1/dir2/dir3")
	c.Assert(Push("dir4"), check.Equals, tmpDir+"/dir1/dir2/dir3/dir4")
	c.Assert(Push("dir9"), check.Equals, "")
	c.Assert(Pop(), check.Equals, tmpDir+"/dir1/dir2/dir3")
	c.Assert(Pop(), check.Equals, tmpDir+"/dir1")
	c.Assert(Pop(), check.Equals, tmpDir)
	c.Assert(Pop(), check.Equals, tmpDir)
}
開發者ID:essentialkaos,項目名稱:ek,代碼行數:25,代碼來源:fs_test.go

示例13: TestInteger

func (s *KNFSuite) TestInteger(c *check.C) {
	var err error

	err = Global(s.ConfigPath)

	c.Assert(global, check.NotNil)
	c.Assert(err, check.IsNil)

	c.Assert(GetI("integer:test1"), check.Equals, 1)
	c.Assert(GetI("integer:test2"), check.Equals, -5)
	c.Assert(GetI("integer:test3"), check.Equals, 10000000)
	c.Assert(GetI("integer:test4"), check.Equals, 0)
	c.Assert(GetI("integer:test5"), check.Equals, 0xFF)
	c.Assert(GetF("integer:test6"), check.Equals, 123.4)
	c.Assert(GetF("integer:test7"), check.Equals, 123.456789)
	c.Assert(GetF("integer:test8"), check.Equals, 0.0)
	c.Assert(GetI("integer:test8"), check.Equals, 0)
	c.Assert(GetF("integer:test9"), check.Equals, 0.0)
}
開發者ID:essentialkaos,項目名稱:ek,代碼行數:19,代碼來源:knf_test.go

示例14: TestBoolean

func (s *KNFSuite) TestBoolean(c *check.C) {
	var err error

	err = Global(s.ConfigPath)

	c.Assert(global, check.NotNil)
	c.Assert(err, check.IsNil)

	c.Assert(GetB("boolean:test1"), check.Equals, true)
	c.Assert(GetB("boolean:test2"), check.Equals, false)
	c.Assert(GetB("boolean:test3"), check.Equals, false)
	c.Assert(GetB("boolean:test4"), check.Equals, true)
	c.Assert(GetB("boolean:test5"), check.Equals, false)
	c.Assert(GetB("boolean:test6"), check.Equals, true)
}
開發者ID:essentialkaos,項目名稱:ek,代碼行數:15,代碼來源:knf_test.go

示例15: TestStrings

func (s *KNFSuite) TestStrings(c *check.C) {
	var err error

	err = Global(s.ConfigPath)

	c.Assert(global, check.NotNil)
	c.Assert(err, check.IsNil)

	c.Assert(GetS("string:test1"), check.Equals, "test")
	c.Assert(GetS("string:test2"), check.Equals, "true")
	c.Assert(GetS("string:test3"), check.Equals, "4500")
	c.Assert(GetS("string:test4"), check.Equals, "!$%^&")
	c.Assert(GetS("string:test5"), check.Equals, "long long long long text for test")
}
開發者ID:essentialkaos,項目名稱:ek,代碼行數:14,代碼來源:knf_test.go


注:本文中的pkg/re/check/v1.C類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。