diff options
author | Samuel Stauffer <samuel@descolada.com> | 2014-03-19 21:57:32 +0100 |
---|---|---|
committer | Samuel Stauffer <samuel@descolada.com> | 2014-03-19 21:57:59 +0100 |
commit | 222854694e922344f18910ce3704115d08ca30cb (patch) | |
tree | 62d54db042f04993a4f89b780f0afb02b9a67e18 /filter_test.go | |
parent | connection handling (diff) | |
download | ldap-222854694e922344f18910ce3704115d08ca30cb.tar ldap-222854694e922344f18910ce3704115d08ca30cb.tar.gz ldap-222854694e922344f18910ce3704115d08ca30cb.tar.bz2 ldap-222854694e922344f18910ce3704115d08ca30cb.tar.lz ldap-222854694e922344f18910ce3704115d08ca30cb.tar.xz ldap-222854694e922344f18910ce3704115d08ca30cb.tar.zst ldap-222854694e922344f18910ce3704115d08ca30cb.zip |
Diffstat (limited to 'filter_test.go')
-rw-r--r-- | filter_test.go | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/filter_test.go b/filter_test.go index d380b23..4c4ce65 100644 --- a/filter_test.go +++ b/filter_test.go @@ -1,44 +1,45 @@ package ldap import ( - "github.com/marcsauter/asn1-ber" "testing" + + "github.com/SpruceHealth/asn1-ber" ) -type compile_test struct { - filter_str string - filter_type int +type compileTest struct { + filterStr string + filterType int } -var test_filters = []compile_test{ - compile_test{filter_str: "(&(sn=Miller)(givenName=Bob))", filter_type: FilterAnd}, - compile_test{filter_str: "(|(sn=Miller)(givenName=Bob))", filter_type: FilterOr}, - compile_test{filter_str: "(!(sn=Miller))", filter_type: FilterNot}, - compile_test{filter_str: "(sn=Miller)", filter_type: FilterEqualityMatch}, - compile_test{filter_str: "(sn=Mill*)", filter_type: FilterSubstrings}, - compile_test{filter_str: "(sn=*Mill)", filter_type: FilterSubstrings}, - compile_test{filter_str: "(sn=*Mill*)", filter_type: FilterSubstrings}, - compile_test{filter_str: "(sn>=Miller)", filter_type: FilterGreaterOrEqual}, - compile_test{filter_str: "(sn<=Miller)", filter_type: FilterLessOrEqual}, - compile_test{filter_str: "(sn=*)", filter_type: FilterPresent}, - compile_test{filter_str: "(sn~=Miller)", filter_type: FilterApproxMatch}, - // compile_test{ filter_str: "()", filter_type: FilterExtensibleMatch }, +var testFilters = []compileTest{ + compileTest{filterStr: "(&(sn=Miller)(givenName=Bob))", filterType: FilterAnd}, + compileTest{filterStr: "(|(sn=Miller)(givenName=Bob))", filterType: FilterOr}, + compileTest{filterStr: "(!(sn=Miller))", filterType: FilterNot}, + compileTest{filterStr: "(sn=Miller)", filterType: FilterEqualityMatch}, + compileTest{filterStr: "(sn=Mill*)", filterType: FilterSubstrings}, + compileTest{filterStr: "(sn=*Mill)", filterType: FilterSubstrings}, + compileTest{filterStr: "(sn=*Mill*)", filterType: FilterSubstrings}, + compileTest{filterStr: "(sn>=Miller)", filterType: FilterGreaterOrEqual}, + compileTest{filterStr: "(sn<=Miller)", filterType: FilterLessOrEqual}, + compileTest{filterStr: "(sn=*)", filterType: FilterPresent}, + compileTest{filterStr: "(sn~=Miller)", filterType: FilterApproxMatch}, + // compileTest{ filterStr: "()", filterType: FilterExtensibleMatch }, } func TestFilter(t *testing.T) { // Test Compiler and Decompiler - for _, i := range test_filters { - filter, err := CompileFilter(i.filter_str) + for _, i := range testFilters { + filter, err := CompileFilter(i.filterStr) if err != nil { - t.Errorf("Problem compiling %s - %s", err.String()) - } else if filter.Tag != uint8(i.filter_type) { - t.Errorf("%q Expected %q got %q", i.filter_str, FilterMap[uint64(i.filter_type)], FilterMap[uint64(filter.Tag)]) + t.Errorf("Problem compiling %s - %s", i.filterStr, err.String()) + } else if filter.Tag != uint8(i.filterType) { + t.Errorf("%q Expected %q got %q", i.filterStr, FilterMap[uint64(i.filterType)], FilterMap[uint64(filter.Tag)]) } else { o, err := DecompileFilter(filter) if err != nil { - t.Errorf("Problem compiling %s - %s", i, err.String()) - } else if i.filter_str != o { - t.Errorf("%q expected, got %q", i.filter_str, o) + t.Errorf("Problem compiling %s - %s", i.filterStr, err.String()) + } else if i.filterStr != o { + t.Errorf("%q expected, got %q", i.filterStr, o) } } } @@ -46,11 +47,11 @@ func TestFilter(t *testing.T) { func BenchmarkFilterCompile(b *testing.B) { b.StopTimer() - filters := make([]string, len(test_filters)) + filters := make([]string, len(testFilters)) // Test Compiler and Decompiler - for idx, i := range test_filters { - filters[idx] = i.filter_str + for idx, i := range testFilters { + filters[idx] = i.filterStr } max_idx := len(filters) @@ -62,11 +63,11 @@ func BenchmarkFilterCompile(b *testing.B) { func BenchmarkFilterDecompile(b *testing.B) { b.StopTimer() - filters := make([]*ber.Packet, len(test_filters)) + filters := make([]*ber.Packet, len(testFilters)) // Test Compiler and Decompiler - for idx, i := range test_filters { - filters[idx], _ = CompileFilter(i.filter_str) + for idx, i := range testFilters { + filters[idx], _ = CompileFilter(i.filterStr) } max_idx := len(filters) |