diff options
author | Gregory Haik <gregory.haik@trustelem.com> | 2014-08-01 18:16:52 +0200 |
---|---|---|
committer | Gregory Haik <gregory.haik@trustelem.com> | 2014-08-01 18:16:52 +0200 |
commit | 81cd5e4d4d650e8c0c34b37d6e3334578e97efb2 (patch) | |
tree | 6914f68c64b3e6f4a7b118d44f212c2c35e2f928 /filter_test.go | |
parent | Switch asn1-ber dependency to "github.com/vanackere/asn1-ber" (diff) | |
download | ldap-81cd5e4d4d650e8c0c34b37d6e3334578e97efb2.tar ldap-81cd5e4d4d650e8c0c34b37d6e3334578e97efb2.tar.gz ldap-81cd5e4d4d650e8c0c34b37d6e3334578e97efb2.tar.bz2 ldap-81cd5e4d4d650e8c0c34b37d6e3334578e97efb2.tar.lz ldap-81cd5e4d4d650e8c0c34b37d6e3334578e97efb2.tar.xz ldap-81cd5e4d4d650e8c0c34b37d6e3334578e97efb2.tar.zst ldap-81cd5e4d4d650e8c0c34b37d6e3334578e97efb2.zip |
Diffstat (limited to 'filter_test.go')
-rw-r--r-- | filter_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/filter_test.go b/filter_test.go index 0a63949..e78caa1 100644 --- a/filter_test.go +++ b/filter_test.go @@ -45,6 +45,42 @@ func TestFilter(t *testing.T) { } } +func TestDecodePresentFilter(t *testing.T) { + + bs := []byte{0x87, 0x06, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72} // ~ (member=*) + + p := ber.DecodePacket(bs) + f, err := DecompileFilter(p) + if err != nil { + t.Errorf("--- CAN'T DECODE & DECOMPILE FILTER") + return + } + if f != "(member=*)" { + t.Errorf("expected (member=*), got %s", f) + } + +} + +func TestEncodeDecodePresentFilter(t *testing.T) { + f := "(member=*)" + p, err := CompileFilter(f) + if err != nil { + t.Errorf("cant compile filter") + return + } + bytes := p.Bytes() + + p2 := ber.DecodePacket(bytes) + f2, err := DecompileFilter(p2) + if err != nil { + t.Errorf("cant decompile filter") + return + } + if f != f2 { + t.Errorf("encode/decode changed filter") + } +} + func BenchmarkFilterCompile(b *testing.B) { b.StopTimer() filters := make([]string, len(testFilters)) |