Exemple #1
0
func TestKeys(t *testing.T) {
	Convey("Testing Keys()", t, func() {
		var keys sort.StringSlice
		c := NewConfig(Nodes([]string{"domains", "hosts"}))
		So(c.ReadCfg(&CFGstatic{Cfg: tdata.Cfg}), ShouldBeNil)

		So(c.sortKeys(), ShouldResemble, sort.StringSlice{"blacklist", "domains", "hosts"})

		So(c.GetAll().Names(), ShouldResemble, sort.StringSlice{"includes.[1]", "includes.[9]", "malc0de", "malwaredomains.com", "openphish", "raw.github.com", "simple_tracking", "sysctl.org", "tasty", "volkerschatz", "yoyo", "zeus"})

		for _, k := range []string{"a", "b", "c", "z", "q", "s", "e", "i", "x", "m"} {
			keys = append(keys, k)
		}

		So(keys.Len(), ShouldEqual, 10)
	})
}
Exemple #2
0
func (r dynamicImage) calcCalls(source *arrowSlice, func_name string, call_depth uint, buffer *bytes.Buffer, visitedCalls sort.StringSlice) {
	for _, v := range *source {
		if v.from < func_name {
			continue
		} else if v.from > func_name {
			break
		}
		buffer.WriteString(v.attr)
		buffer.WriteString("\n")

		idx := visitedCalls.Search(v.to)
		if idx < visitedCalls.Len() && visitedCalls[idx] == v.to {
		} else if r.callDepth == 0 || call_depth+1 < r.callDepth {
			visitedCalls = append(visitedCalls, v.to)
			visitedCalls.Sort()
			r.calcCalls(source, v.to, call_depth+1, buffer, visitedCalls)
		}
	}
}