コード例 #1
0
func TestProcessFmt134(t *testing.T) {
	b := New()
	config.SetDistance(1000)
	config.SetRange(500)
	config.SetChoices(3)
	b.addSignature(tests.TestFmts[134])
	saver := persist.NewLoadSaver(nil)
	b.Save(saver)
	loader := persist.NewLoadSaver(saver.Bytes())
	b = Load(loader)
	if len(b.keyFrames[0]) != 8 {
		for _, v := range b.keyFrames[0] {
			t.Errorf("%s\n", v)
		}
	}
	for _, t := range b.tests {
		t.maxLeftDistance = maxLength(t.left)
		t.maxRightDistance = maxLength(t.right)
	}
	if len(b.tests) != 8 {
		for _, v := range b.tests {
			t.Error(v.maxRightDistance)
			t.Error(v.right)
		}
	}
}
コード例 #2
0
func TestProcess(t *testing.T) {
	b := New()
	config.SetDistance(8192)()
	config.SetRange(2059)()
	config.SetChoices(9)()
	for i, v := range tests.TestSignatures {
		err := b.addSignature(v)
		if err != nil {
			t.Errorf("Unexpected error adding persist; sig %v; error %v", i, v)
		}
	}
	saver := persist.NewLoadSaver(nil)
	b.Save(saver)
	loader := persist.NewLoadSaver(saver.Bytes())
	b = Load(loader)
	if len(b.keyFrames) != 6 {
		t.Errorf("Expecting 6 keyframe slices, got %d", len(b.keyFrames))
	}
	var tl int
	for _, v := range b.keyFrames {
		tl += len(v)
	}
	if tl != 12 {
		t.Errorf("Expecting a total of 12 keyframes, got %d", tl)
	}
	if len(b.tests) != 9 {
		t.Errorf("Expecting a total of 9 tests, got %d", len(b.tests))
	}
	if len(b.bofSeq.set) != 4 {
		t.Errorf("Expecting 4 BOF seqs, got %d", len(b.bofSeq.set))
	}
	e1 := wac.Seq{[]int64{0}, []wac.Choice{wac.Choice{[]byte{'t', 'e', 's', 't'}}}}
	if !seqEquals(b.bofSeq.set[0], e1) {
		t.Errorf("Expecting %v to equal %v", b.bofSeq.set[0], e1)
	}
	e2 := wac.Seq{[]int64{-1}, []wac.Choice{wac.Choice{[]byte{'t', 'e', 's', 't'}}}}
	if seqEquals(b.bofSeq.set[0], e2) {
		t.Errorf("Not expecting %v to equal %v", b.bofSeq.set[0], e2)
	}
	if len(b.eofSeq.set) != 2 {
		t.Errorf("Expecting two EOF seqs, got %d, first is %v", len(b.eofSeq.set), b.eofSeq.set[0])
	}
	if len(b.bofFrames.set) != 1 {
		t.Errorf("Expecting one BOF Frame, got %d", len(b.bofFrames.set))
	}
	if len(b.eofFrames.set) != 0 {
		t.Errorf("Expecting no EOF frame, got %d", len(b.eofFrames.set))
	}
}
コード例 #3
0
func TestProcessFmt418(t *testing.T) {
	b := New()
	config.SetDistance(2000)()
	config.SetRange(500)()
	config.SetChoices(10)()
	b.addSignature(tests.TestFmts[418])
	saver := persist.NewLoadSaver(nil)
	b.Save(saver)
	loader := persist.NewLoadSaver(saver.Bytes())
	b = Load(loader)
	if len(b.keyFrames[0]) != 2 {
		for _, v := range b.keyFrames[0] {
			t.Errorf("%s\n", v)
		}
	}
}
コード例 #4
0
ファイル: roy.go プロジェクト: TidyHuang/siegfried
func buildOptions() []config.Option {
	if *home != config.Home() {
		config.SetHome(*home)
	}
	opts := []config.Option{}
	if *droid != config.Droid() {
		opts = append(opts, config.SetDroid(*droid))
	}
	if *container != config.Container() {
		opts = append(opts, config.SetContainer(*container))
	}
	if *reports != config.Reports() {
		opts = append(opts, config.SetReports(*reports))
	}
	if *name != config.Name() {
		opts = append(opts, config.SetName(*name))
	}
	if *details != config.Details() {
		opts = append(opts, config.SetDetails(*details))
	}
	if *extend != "" {
		opts = append(opts, config.SetExtend(expandSets(*extend)))
	}
	if *extendc != "" {
		if *extend == "" {
			fmt.Println(
				`roy: warning! Unless the container extension only extends formats defined in 
the DROID signature file you should also include a regular signature extension 
(-extend) that includes a FileFormatCollection element defining the new formats.`)
		}
		opts = append(opts, config.SetExtendC(expandSets(*extendc)))
	}
	if *include != "" {
		opts = append(opts, config.SetLimit(expandSets(*include)))
	}
	if *exclude != "" {
		opts = append(opts, config.SetExclude(expandSets(*exclude)))
	}
	if *bof != 0 {
		opts = append(opts, config.SetBOF(*bof))
	}
	if *eof != 0 {
		opts = append(opts, config.SetEOF(*eof))
	}
	if *noeof {
		opts = append(opts, config.SetNoEOF())
	}
	if *nopriority {
		opts = append(opts, config.SetNoPriority())
	}
	if *nocontainer {
		opts = append(opts, config.SetNoContainer())
	}
	if *notext {
		opts = append(opts, config.SetNoText())
	}
	if *noext {
		opts = append(opts, config.SetNoExt())
	}
	if *noreports {
		opts = append(opts, config.SetNoReports())
	}
	if *doubleup {
		opts = append(opts, config.SetDoubleUp())
	}
	if *rng != config.Range() {
		opts = append(opts, config.SetRange(*rng))
	}
	if *distance != config.Distance() {
		opts = append(opts, config.SetDistance(*distance))
	}
	if *choices != config.Choices() {
		opts = append(opts, config.SetChoices(*choices))
	}
	return opts
}
コード例 #5
0
ファイル: roy.go プロジェクト: glepore70/siegfried
func buildOptions() []config.Option {
	if *home != config.Home() {
		config.SetHome(*home)
	}
	opts := []config.Option{}
	if *droid != config.Droid() {
		opts = append(opts, config.SetDroid(*droid))
	}
	if *container != config.Container() {
		opts = append(opts, config.SetContainer(*container))
	}
	if *reports != config.Reports() {
		opts = append(opts, config.SetReports(*reports))
	}
	if *name != config.Name() {
		opts = append(opts, config.SetName(*name))
	}
	if *details != config.Details() {
		opts = append(opts, config.SetDetails(*details))
	}
	if *extend != "" {
		opts = append(opts, config.SetExtend(expandSets(*extend)))
	}
	if *extendc != "" {
		opts = append(opts, config.SetExtendC(expandSets(*extendc)))
	}
	if *include != "" {
		opts = append(opts, config.SetLimit(expandSets(*include)))
	}
	if *exclude != "" {
		opts = append(opts, config.SetExclude(expandSets(*exclude)))
	}
	if *bof != 0 {
		opts = append(opts, config.SetBOF(*bof))
	}
	if *eof != 0 {
		opts = append(opts, config.SetEOF(*eof))
	}
	if *noeof {
		opts = append(opts, config.SetNoEOF())
	}
	if *nopriority {
		opts = append(opts, config.SetNoPriority())
	}
	if *nocontainer {
		opts = append(opts, config.SetNoContainer())
	}
	if *notext {
		opts = append(opts, config.SetNoText())
	}
	if *noreports {
		opts = append(opts, config.SetNoReports())
	}
	if *rng != config.Range() {
		opts = append(opts, config.SetRange(*rng))
	}
	if *distance != config.Distance() {
		opts = append(opts, config.SetDistance(*distance))
	}
	if *choices != config.Choices() {
		opts = append(opts, config.SetChoices(*choices))
	}
	return opts
}