diff --git a/Makefile.am b/Makefile.am index 7dd6a8c0..544c9927 100644 --- a/Makefile.am +++ b/Makefile.am @@ -963,6 +963,35 @@ go_wrappers += test/sh/bindings.go.RangeSearchString.sh go_wrappers += test/sh/bindings.go.RegexSearch.sh shell_wrappers += $(go_wrappers) +rust_wrappers = +rust_wrappers += test/sh/bindings.rust.Basic.sh +rust_wrappers += test/sh/bindings.rust.BasicSearch.sh +rust_wrappers += test/sh/bindings.rust.CondPut.sh +rust_wrappers += test/sh/bindings.rust.DataTypeFloat.sh +rust_wrappers += test/sh/bindings.rust.DataTypeInt.sh +rust_wrappers += test/sh/bindings.rust.DataTypeListFloat.sh +rust_wrappers += test/sh/bindings.rust.DataTypeListInt.sh +rust_wrappers += test/sh/bindings.rust.DataTypeListString.sh +rust_wrappers += test/sh/bindings.rust.DataTypeMapFloatFloat.sh +rust_wrappers += test/sh/bindings.rust.DataTypeMapFloatInt.sh +rust_wrappers += test/sh/bindings.rust.DataTypeMapFloatString.sh +rust_wrappers += test/sh/bindings.rust.DataTypeMapIntFloat.sh +rust_wrappers += test/sh/bindings.rust.DataTypeMapIntInt.sh +rust_wrappers += test/sh/bindings.rust.DataTypeMapIntString.sh +rust_wrappers += test/sh/bindings.rust.DataTypeMapStringFloat.sh +rust_wrappers += test/sh/bindings.rust.DataTypeMapStringInt.sh +rust_wrappers += test/sh/bindings.rust.DataTypeMapStringString.sh +rust_wrappers += test/sh/bindings.rust.DataTypeSetFloat.sh +rust_wrappers += test/sh/bindings.rust.DataTypeSetInt.sh +rust_wrappers += test/sh/bindings.rust.DataTypeSetString.sh +rust_wrappers += test/sh/bindings.rust.DataTypeString.sh +rust_wrappers += test/sh/bindings.rust.LengthString.sh +rust_wrappers += test/sh/bindings.rust.MultiAttribute.sh +rust_wrappers += test/sh/bindings.rust.RangeSearchInt.sh +rust_wrappers += test/sh/bindings.rust.RangeSearchString.sh +rust_wrappers += test/sh/bindings.rust.RegexSearch.sh +shell_wrappers += $(rust_wrappers) + if ENABLE_ADMIN if ENABLE_CLIENT if ENABLE_PYTHON_BINDINGS @@ -984,6 +1013,10 @@ if ENABLE_RUBY_BINDINGS TESTS += $(ruby_wrappers) endif +if ENABLE_RUST_BINDINGS +TESTS += $(rust_wrappers) +endif + endif # ENABLE_PYTHON_BINDINGS endif # ENABLE_CLIENT endif # ENABLE_ADMIN diff --git a/bindings/go/client/client.go b/bindings/go/client/client.go index 392df3a9..a13a6eb5 100644 --- a/bindings/go/client/client.go +++ b/bindings/go/client/client.go @@ -1131,18 +1131,17 @@ func (client *Client) AsynccallSpacenameKeyStatusAttributes(stub func(client *C. inner.ops[reqid] = done } else { if c_status != SUCCESS { - err = &Error{Status(c_status), - C.GoString(C.hyperdex_client_error_message(inner.ptr)), - C.GoString(C.hyperdex_client_error_location(inner.ptr))} - } + err = &Error{Status(c_status), + C.GoString(C.hyperdex_client_error_message(inner.ptr)), + C.GoString(C.hyperdex_client_error_location(inner.ptr))}} } inner.mutex.Unlock() if reqid >= 0 { - rz := <-done - if c_status != SUCCESS { - err = &rz - err.Status = Status(c_status) - } + rz := <-done + if c_status != SUCCESS { + err = &rz + err.Status = Status(c_status) + } } if c_status == SUCCESS { var er error @@ -1193,18 +1192,17 @@ func (client *Client) AsynccallSpacenameKeyAttributenamesStatusAttributes(stub f inner.ops[reqid] = done } else { if c_status != SUCCESS { - err = &Error{Status(c_status), - C.GoString(C.hyperdex_client_error_message(inner.ptr)), - C.GoString(C.hyperdex_client_error_location(inner.ptr))} - } + err = &Error{Status(c_status), + C.GoString(C.hyperdex_client_error_message(inner.ptr)), + C.GoString(C.hyperdex_client_error_location(inner.ptr))}} } inner.mutex.Unlock() if reqid >= 0 { - rz := <-done - if c_status != SUCCESS { - err = &rz - err.Status = Status(c_status) - } + rz := <-done + if c_status != SUCCESS { + err = &rz + err.Status = Status(c_status) + } } if c_status == SUCCESS { var er error @@ -1253,18 +1251,17 @@ func (client *Client) AsynccallSpacenameKeyAttributesStatus(stub func(client *C. inner.ops[reqid] = done } else { if c_status != SUCCESS { - err = &Error{Status(c_status), - C.GoString(C.hyperdex_client_error_message(inner.ptr)), - C.GoString(C.hyperdex_client_error_location(inner.ptr))} - } + err = &Error{Status(c_status), + C.GoString(C.hyperdex_client_error_message(inner.ptr)), + C.GoString(C.hyperdex_client_error_location(inner.ptr))}} } inner.mutex.Unlock() if reqid >= 0 { - rz := <-done - if c_status != SUCCESS { - err = &rz - err.Status = Status(c_status) - } + rz := <-done + if c_status != SUCCESS { + err = &rz + err.Status = Status(c_status) + } } return } @@ -1312,18 +1309,17 @@ func (client *Client) AsynccallSpacenameKeyPredicatesAttributesStatus(stub func( inner.ops[reqid] = done } else { if c_status != SUCCESS { - err = &Error{Status(c_status), - C.GoString(C.hyperdex_client_error_message(inner.ptr)), - C.GoString(C.hyperdex_client_error_location(inner.ptr))} - } + err = &Error{Status(c_status), + C.GoString(C.hyperdex_client_error_message(inner.ptr)), + C.GoString(C.hyperdex_client_error_location(inner.ptr))}} } inner.mutex.Unlock() if reqid >= 0 { - rz := <-done - if c_status != SUCCESS { - err = &rz - err.Status = Status(c_status) - } + rz := <-done + if c_status != SUCCESS { + err = &rz + err.Status = Status(c_status) + } } return } @@ -1365,18 +1361,17 @@ func (client *Client) AsynccallSpacenamePredicatesAttributesStatusCount(stub fun inner.ops[reqid] = done } else { if c_status != SUCCESS { - err = &Error{Status(c_status), - C.GoString(C.hyperdex_client_error_message(inner.ptr)), - C.GoString(C.hyperdex_client_error_location(inner.ptr))} - } + err = &Error{Status(c_status), + C.GoString(C.hyperdex_client_error_message(inner.ptr)), + C.GoString(C.hyperdex_client_error_location(inner.ptr))}} } inner.mutex.Unlock() if reqid >= 0 { - rz := <-done - if c_status != SUCCESS { - err = &rz - err.Status = Status(c_status) - } + rz := <-done + if c_status != SUCCESS { + err = &rz + err.Status = Status(c_status) + } } if c_status == SUCCESS { count = uint64(c_count) @@ -1413,18 +1408,17 @@ func (client *Client) AsynccallSpacenameKeyStatus(stub func(client *C.struct_hyp inner.ops[reqid] = done } else { if c_status != SUCCESS { - err = &Error{Status(c_status), - C.GoString(C.hyperdex_client_error_message(inner.ptr)), - C.GoString(C.hyperdex_client_error_location(inner.ptr))} - } + err = &Error{Status(c_status), + C.GoString(C.hyperdex_client_error_message(inner.ptr)), + C.GoString(C.hyperdex_client_error_location(inner.ptr))}} } inner.mutex.Unlock() if reqid >= 0 { - rz := <-done - if c_status != SUCCESS { - err = &rz - err.Status = Status(c_status) - } + rz := <-done + if c_status != SUCCESS { + err = &rz + err.Status = Status(c_status) + } } return } @@ -1465,18 +1459,17 @@ func (client *Client) AsynccallSpacenameKeyPredicatesStatus(stub func(client *C. inner.ops[reqid] = done } else { if c_status != SUCCESS { - err = &Error{Status(c_status), - C.GoString(C.hyperdex_client_error_message(inner.ptr)), - C.GoString(C.hyperdex_client_error_location(inner.ptr))} - } + err = &Error{Status(c_status), + C.GoString(C.hyperdex_client_error_message(inner.ptr)), + C.GoString(C.hyperdex_client_error_location(inner.ptr))}} } inner.mutex.Unlock() if reqid >= 0 { - rz := <-done - if c_status != SUCCESS { - err = &rz - err.Status = Status(c_status) - } + rz := <-done + if c_status != SUCCESS { + err = &rz + err.Status = Status(c_status) + } } return } @@ -1511,18 +1504,17 @@ func (client *Client) AsynccallSpacenamePredicatesStatusCount(stub func(client * inner.ops[reqid] = done } else { if c_status != SUCCESS { - err = &Error{Status(c_status), - C.GoString(C.hyperdex_client_error_message(inner.ptr)), - C.GoString(C.hyperdex_client_error_location(inner.ptr))} - } + err = &Error{Status(c_status), + C.GoString(C.hyperdex_client_error_message(inner.ptr)), + C.GoString(C.hyperdex_client_error_location(inner.ptr))}} } inner.mutex.Unlock() if reqid >= 0 { - rz := <-done - if c_status != SUCCESS { - err = &rz - err.Status = Status(c_status) - } + rz := <-done + if c_status != SUCCESS { + err = &rz + err.Status = Status(c_status) + } } if c_status == SUCCESS { count = uint64(c_count) @@ -1566,18 +1558,17 @@ func (client *Client) AsynccallSpacenameKeyMapattributesStatus(stub func(client inner.ops[reqid] = done } else { if c_status != SUCCESS { - err = &Error{Status(c_status), - C.GoString(C.hyperdex_client_error_message(inner.ptr)), - C.GoString(C.hyperdex_client_error_location(inner.ptr))} - } + err = &Error{Status(c_status), + C.GoString(C.hyperdex_client_error_message(inner.ptr)), + C.GoString(C.hyperdex_client_error_location(inner.ptr))}} } inner.mutex.Unlock() if reqid >= 0 { - rz := <-done - if c_status != SUCCESS { - err = &rz - err.Status = Status(c_status) - } + rz := <-done + if c_status != SUCCESS { + err = &rz + err.Status = Status(c_status) + } } return } @@ -1625,18 +1616,17 @@ func (client *Client) AsynccallSpacenameKeyPredicatesMapattributesStatus(stub fu inner.ops[reqid] = done } else { if c_status != SUCCESS { - err = &Error{Status(c_status), - C.GoString(C.hyperdex_client_error_message(inner.ptr)), - C.GoString(C.hyperdex_client_error_location(inner.ptr))} - } + err = &Error{Status(c_status), + C.GoString(C.hyperdex_client_error_message(inner.ptr)), + C.GoString(C.hyperdex_client_error_location(inner.ptr))}} } inner.mutex.Unlock() if reqid >= 0 { - rz := <-done - if c_status != SUCCESS { - err = &rz - err.Status = Status(c_status) - } + rz := <-done + if c_status != SUCCESS { + err = &rz + err.Status = Status(c_status) + } } return } @@ -1678,18 +1668,17 @@ func (client *Client) AsynccallSpacenamePredicatesMapattributesStatusCount(stub inner.ops[reqid] = done } else { if c_status != SUCCESS { - err = &Error{Status(c_status), - C.GoString(C.hyperdex_client_error_message(inner.ptr)), - C.GoString(C.hyperdex_client_error_location(inner.ptr))} - } + err = &Error{Status(c_status), + C.GoString(C.hyperdex_client_error_message(inner.ptr)), + C.GoString(C.hyperdex_client_error_location(inner.ptr))}} } inner.mutex.Unlock() if reqid >= 0 { - rz := <-done - if c_status != SUCCESS { - err = &rz - err.Status = Status(c_status) - } + rz := <-done + if c_status != SUCCESS { + err = &rz + err.Status = Status(c_status) + } } if c_status == SUCCESS { count = uint64(c_count) @@ -1711,7 +1700,7 @@ func (client *Client) IteratorSpacenamePredicatesStatusAttributes(stub func(clie er = client.convertSpacename(arena, spacename, &c_space) if er != nil { err := Error{Status(WRONGTYPE), er.Error(), ""} - errs <- err + errs<-err close(attrs) close(errs) return @@ -1719,7 +1708,7 @@ func (client *Client) IteratorSpacenamePredicatesStatusAttributes(stub func(clie er = client.convertPredicates(arena, predicates, &c_checks, &c_checks_sz) if er != nil { err := Error{Status(WRONGTYPE), er.Error(), ""} - errs <- err + errs<-err close(attrs) close(errs) return @@ -1735,12 +1724,12 @@ func (client *Client) IteratorSpacenamePredicatesStatusAttributes(stub func(clie inner.searches[reqid] = &c_iter } else { err = Error{Status(c_iter.status), - C.GoString(C.hyperdex_client_error_message(inner.ptr)), - C.GoString(C.hyperdex_client_error_location(inner.ptr))} + C.GoString(C.hyperdex_client_error_message(inner.ptr)), + C.GoString(C.hyperdex_client_error_location(inner.ptr))} } inner.mutex.Unlock() if reqid < 0 { - errs <- err + errs<-err close(attrs) close(errs) } @@ -1777,18 +1766,17 @@ func (client *Client) AsynccallSpacenamePredicatesStatusDescription(stub func(cl inner.ops[reqid] = done } else { if c_status != SUCCESS { - err = &Error{Status(c_status), - C.GoString(C.hyperdex_client_error_message(inner.ptr)), - C.GoString(C.hyperdex_client_error_location(inner.ptr))} - } + err = &Error{Status(c_status), + C.GoString(C.hyperdex_client_error_message(inner.ptr)), + C.GoString(C.hyperdex_client_error_location(inner.ptr))}} } inner.mutex.Unlock() if reqid >= 0 { - rz := <-done - if c_status != SUCCESS { - err = &rz - err.Status = Status(c_status) - } + rz := <-done + if c_status != SUCCESS { + err = &rz + err.Status = Status(c_status) + } } if c_status == SUCCESS { desc = C.GoString(c_description) @@ -1813,7 +1801,7 @@ func (client *Client) IteratorSpacenamePredicatesSortbyLimitMaxminStatusAttribut er = client.convertSpacename(arena, spacename, &c_space) if er != nil { err := Error{Status(WRONGTYPE), er.Error(), ""} - errs <- err + errs<-err close(attrs) close(errs) return @@ -1821,7 +1809,7 @@ func (client *Client) IteratorSpacenamePredicatesSortbyLimitMaxminStatusAttribut er = client.convertPredicates(arena, predicates, &c_checks, &c_checks_sz) if er != nil { err := Error{Status(WRONGTYPE), er.Error(), ""} - errs <- err + errs<-err close(attrs) close(errs) return @@ -1829,7 +1817,7 @@ func (client *Client) IteratorSpacenamePredicatesSortbyLimitMaxminStatusAttribut er = client.convertSortby(arena, sortby, &c_sort_by) if er != nil { err := Error{Status(WRONGTYPE), er.Error(), ""} - errs <- err + errs<-err close(attrs) close(errs) return @@ -1837,7 +1825,7 @@ func (client *Client) IteratorSpacenamePredicatesSortbyLimitMaxminStatusAttribut er = client.convertLimit(arena, limit, &c_limit) if er != nil { err := Error{Status(WRONGTYPE), er.Error(), ""} - errs <- err + errs<-err close(attrs) close(errs) return @@ -1845,7 +1833,7 @@ func (client *Client) IteratorSpacenamePredicatesSortbyLimitMaxminStatusAttribut er = client.convertMaxmin(arena, maxmin, &c_maxmin) if er != nil { err := Error{Status(WRONGTYPE), er.Error(), ""} - errs <- err + errs<-err close(attrs) close(errs) return @@ -1861,12 +1849,12 @@ func (client *Client) IteratorSpacenamePredicatesSortbyLimitMaxminStatusAttribut inner.searches[reqid] = &c_iter } else { err = Error{Status(c_iter.status), - C.GoString(C.hyperdex_client_error_message(inner.ptr)), - C.GoString(C.hyperdex_client_error_location(inner.ptr))} + C.GoString(C.hyperdex_client_error_message(inner.ptr)), + C.GoString(C.hyperdex_client_error_location(inner.ptr))} } inner.mutex.Unlock() if reqid < 0 { - errs <- err + errs<-err close(attrs) close(errs) } diff --git a/client/c.cc b/client/c.cc index 94ea46f5..dc1edbc2 100644 --- a/client/c.cc +++ b/client/c.cc @@ -160,13 +160,6 @@ hyperdex_client_error_message(hyperdex_client* _cl) return cl->error_message(); } -HYPERDEX_API void -hyperdex_client_set_type_conversion(hyperdex_client* _cl, bool enabled) -{ - hyperdex::client* cl = reinterpret_cast(_cl); - cl->set_type_conversion(enabled); -} - HYPERDEX_API const char* hyperdex_client_error_location(hyperdex_client* _cl) { diff --git a/configure.ac b/configure.ac index 3b7e76f4..21be65cc 100755 --- a/configure.ac +++ b/configure.ac @@ -210,6 +210,13 @@ if test x"${ruby_bindings}" = xyes; then AX_RUBY_EXT fi +AC_ARG_ENABLE([rust_bindings], [AS_HELP_STRING([--enable-rust-bindings], + [build Rust bindings @<:@default: no@:>@])], + [rust_bindings=${enableval}], [rust_bindings=no]) +if test x"${rust_bindings}" = xyes; then + AX_RUST_EXT +fi + AC_ARG_ENABLE([log-all-messages], [AS_HELP_STRING([--enable-log-all-messages], [enable code to log all messages @<:@default: no@:>@])], [enable_logall=${enableval}], [enable_logall=no]) @@ -220,6 +227,7 @@ fi AM_CONDITIONAL([ENABLE_JAVA_BINDINGS], [test x"${java_bindings}" = xyes]) AM_CONDITIONAL([ENABLE_PYTHON_BINDINGS], [test x"${python_bindings}" = xyes]) AM_CONDITIONAL([ENABLE_RUBY_BINDINGS], [test x"${ruby_bindings}" = xyes]) +AM_CONDITIONAL([ENABLE_RUST_BINDINGS], [test x"${rust_bindings}" = xyes]) AM_CONDITIONAL([ENABLE_YCSB], [test x"${enable_ycsb}" = xyes]) # Optional components diff --git a/maint/generate-bindings-tests.py b/maint/generate-bindings-tests.py index 4418b803..80d05e4e 100644 --- a/maint/generate-bindings-tests.py +++ b/maint/generate-bindings-tests.py @@ -29,6 +29,7 @@ import collections import os import sys +import subprocess def double_quote(x): y = repr(x) @@ -759,6 +760,348 @@ def to_go(self, x): else: raise RuntimeError("Cannot convert {0!r} to go".format(x)) + +class RustGenerator(BindingGenerator): + + def __init__(self): + self.f = None + self.lib_dir = 'rust_hyperdex' + subprocess.call(['git', 'clone', 'https://github.com/derekchiang/rust-hyperdex.git', self.lib_dir]) + subprocess.call(['cargo', 'build'], cwd=self.lib_dir) + + def test(self, name, space): + assert self.f is None + self.count = 0 + self.path = 'test/rust/{0}.rs'.format(name) + precmd = 'rustc -g -L {1} -L {2} -o "${{HYPERDEX_BUILDDIR}}"/test/rust/{0} "${{HYPERDEX_SRCDIR}}"/test/rust/{0}.rs'.format(name, self.lib_dir + '/target/debug', self.lib_dir + '/target/debug/deps') + cmd = '"${{HYPERDEX_BUILDDIR}}"/test/rust/{0}'.format(name) + gen_shell('rust', name, cmd, space, precmd=precmd) + self.f = open(self.path, 'w') + self.f.write(''' +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); +''') + + def finish(self): + self.f.write('}\n') + self.f.flush() + self.f.close() + self.f = None + + def get(self, space, key, expected): + if expected is None: + self.f.write(''' + match client.get({0}, {1}) {{ + Ok(obj) => {{ + panic!("this object should not be found!"); + }}, + Err(err) => (), + }} + '''.format(self.to_rust(space), self.to_rust(key))) + else: + self.f.write('let expected = {0};'.format(self.to_rust(expected))) + self.f.write(''' + match client.get({0}, {1}) {{ + Ok(obj) => {{ + if !sloppyCompareHyper(&obj, &expected) {{ + panic!("expected: {{:?}}\nactual: {{:?}}", expected, obj); + }} + }}, + Err(err) => panic!(err), + }} + '''.format(self.to_rust(space), self.to_rust(key))) + + def get_partial(self, space, key, attrs, expected): + if expected is None: + self.f.write(''' + match client.get_partial({0}, {1}, {2}) {{ + Ok(obj) => {{ + panic!("this object should not be found!"); + }}, + Err(err) => (), + }} + '''.format(self.to_rust(space), self.to_rust(key), self.to_rust(attrs))) + else: + self.f.write('let expected = {0};'.format(self.to_rust(expected))) + self.f.write(''' + match client.get_partial({0}, {1}, {2}) {{ + Ok(obj) => {{ + if !sloppyCompareHyper(&obj, &expected) {{ + panic!("expected: {{:?}}\nactual: {{:?}}", expected, obj); + }} + }}, + Err(err) => panic!(err), + }} + '''.format(self.to_rust(space), self.to_rust(key), self.to_rust(attrs))) + + def put(self, space, key, value, expected): + if expected: + self.f.write(''' + match client.put({0}, {1}, {2}) {{ + Ok(()) => (), + Err(err) => panic!(err), + }} + '''.format(self.to_rust(space), self.to_rust(key), self.to_rust(value))) + else: + self.f.write(''' + match client.put({0}, {1}, {2}) {{ + Ok(()) => panic!("this PUT operation should have failed"), + Err(err) => (), + }} + '''.format(self.to_rust(space), self.to_rust(key), self.to_rust(value))) + + def cond_put(self, space, key, pred, value, expected): + if expected: + self.f.write(''' + match client.cond_put({0}, {1}, {2}, {3}) {{ + Ok(()) => (), + Err(err) => panic!(err), + }} + '''.format(self.to_rust(space), self.to_rust(key), self.to_preds(pred), self.to_rust(value))) + else: + self.f.write(''' + match client.cond_put({0}, {1}, {2}, {3}) {{ + Ok(()) => panic!("this CONDPUT operation should have failed"), + Err(err) => (), + }} + '''.format(self.to_rust(space), self.to_rust(key), self.to_preds(pred), self.to_rust(value))) + + def delete(self, space, key, expected): + self.f.write(''' + match client.del({0}, {1}) {{ + Ok(()) => (), + Err(err) => panic!(err), + }} + '''.format(self.to_rust(space), self.to_rust(key))) + + def search(self, space, pred, expected): + self.f.write(''' + let res = client.search({0}, {1}); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), {2}.len()); + '''.format(self.to_rust(space), self.to_preds(pred), self.to_rust(expected))) + + def to_preds(self, preds): + preds_as_strs = [] + for name, val in preds.iteritems(): + pred = 'EQUALS' + if isinstance(val, Range): + preds_as_strs.append('HyperPredicate::new({0}, {1}, {2})'.format(self.to_rust(name), 'GREATER_EQUAL', self.to_rust(val.x))) + preds_as_strs.append('HyperPredicate::new({0}, {1}, {2})'.format(self.to_rust(name), 'LESS_EQUAL', self.to_rust(val.y))) + continue + elif isinstance(val, LessEqual): + val = val.x + pred = 'LESS_EQUAL' + elif isinstance(val, GreaterEqual): + val = val.x + pred = 'GREATER_EQUAL' + elif isinstance(val, LessThan): + val = val.x + pred = 'LESS_THAN' + elif isinstance(val, GreaterThan): + val = val.x + pred = 'GREATER_THAN' + elif isinstance(val, Regex): + val = val.x + pred = 'REGEX' + elif isinstance(val, LengthEquals): + val = val.x + pred = 'LENGTH_EQUALS' + elif isinstance(val, LengthLessEqual): + val = val.x + pred = 'LENGTH_LESS_EQUAL' + elif isinstance(val, LengthGreaterEqual): + val = val.x + pred = 'LENGTH_GREATER_EQUAL' + preds_as_strs.append('HyperPredicate::new({0}, {1}, {2})'.format(self.to_rust(name), pred, self.to_rust(val))) + return 'vec!(' + ', '.join(preds_as_strs) + ')' + + def to_rust(self, x, inner=False): + if x is True: + return 'true' + elif x is False: + return 'false' + elif x is None: + return 'None' + elif isinstance(x, str): + return 'r'+double_quote(x) + elif isinstance(x, long) or isinstance(x, int): + return '%s as i64' % str(x) + elif isinstance(x, float): + if inner: + return 'F64(%s as f64)' % str(x) + else: + return '%s as f64' % str(x) + elif isinstance(x, list): + if len(x): + s = 'vec!(' + s += ', '.join(['{0}'.format(self.to_rust(v)) for v in x]) + s += ')' + return s + else: + return 'Vec::::new()' + elif isinstance(x, set): + if len(x): + s = '{\n' + s += 'let mut s = BTreeSet::new();\n' + for v in x: + s += 's.insert({0});\n'.format(self.to_rust(v, inner=True)) + s += 's\n}\n' + return s + else: + return 'BTreeSet::>::new()' + elif isinstance(x, dict): + if inner: + if len(x): + s = '{\n' + s += 'let mut m = HashMap::new();\n' + for k, v in x.items(): + s += 'm.insert({}, {});\n'.format(self.to_rust(k, inner=True), self.to_rust(v)) + s += 'm\n}\n' + else: + s = 'HashMap::, Vec>::new()' + return s + elif len(x): + s = 'NewHyperObject!(' + s += ', '.join(['{0}, {1}'.format(self.to_rust(k), self.to_rust(v, inner=isinstance(v, dict))) + for k, v in sorted(x.items())]) + s += ',)' + return s + else: + return "HyperObject::new()" + else: + raise RuntimeError("Cannot convert {0!r} to rust".format(x)) + + class TestGenerator(object): def __init__(self): diff --git a/test/go/Basic.go b/test/go/Basic.go index 3142dd71..20463b51 100644 --- a/test/go/Basic.go +++ b/test/go/Basic.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/BasicSearch.go b/test/go/BasicSearch.go index dae89fd1..38eaf35b 100644 --- a/test/go/BasicSearch.go +++ b/test/go/BasicSearch.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/CondPut.go b/test/go/CondPut.go index 2eb924a4..a90bf384 100644 --- a/test/go/CondPut.go +++ b/test/go/CondPut.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/DataTypeFloat.go b/test/go/DataTypeFloat.go index bb96c452..415b4e63 100644 --- a/test/go/DataTypeFloat.go +++ b/test/go/DataTypeFloat.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/DataTypeInt.go b/test/go/DataTypeInt.go index b5a0101d..7c4f0e05 100644 --- a/test/go/DataTypeInt.go +++ b/test/go/DataTypeInt.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/DataTypeListFloat.go b/test/go/DataTypeListFloat.go index 1c285ad7..49ab89e2 100644 --- a/test/go/DataTypeListFloat.go +++ b/test/go/DataTypeListFloat.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/DataTypeListInt.go b/test/go/DataTypeListInt.go index 92ed5e97..d661cb54 100644 --- a/test/go/DataTypeListInt.go +++ b/test/go/DataTypeListInt.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/DataTypeListString.go b/test/go/DataTypeListString.go index 86deeec5..ee4bb356 100644 --- a/test/go/DataTypeListString.go +++ b/test/go/DataTypeListString.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/DataTypeMapFloatFloat.go b/test/go/DataTypeMapFloatFloat.go index b5a9d2fd..b6e3752a 100644 --- a/test/go/DataTypeMapFloatFloat.go +++ b/test/go/DataTypeMapFloatFloat.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/DataTypeMapFloatInt.go b/test/go/DataTypeMapFloatInt.go index bf7e8216..4b242839 100644 --- a/test/go/DataTypeMapFloatInt.go +++ b/test/go/DataTypeMapFloatInt.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/DataTypeMapFloatString.go b/test/go/DataTypeMapFloatString.go index af8041d1..33de1679 100644 --- a/test/go/DataTypeMapFloatString.go +++ b/test/go/DataTypeMapFloatString.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/DataTypeMapIntFloat.go b/test/go/DataTypeMapIntFloat.go index 40920c82..e9ce86ad 100644 --- a/test/go/DataTypeMapIntFloat.go +++ b/test/go/DataTypeMapIntFloat.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/DataTypeMapIntInt.go b/test/go/DataTypeMapIntInt.go index 5775de2a..93162199 100644 --- a/test/go/DataTypeMapIntInt.go +++ b/test/go/DataTypeMapIntInt.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/DataTypeMapIntString.go b/test/go/DataTypeMapIntString.go index d2bfbd14..57ce30cb 100644 --- a/test/go/DataTypeMapIntString.go +++ b/test/go/DataTypeMapIntString.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/DataTypeMapStringFloat.go b/test/go/DataTypeMapStringFloat.go index c3e93e29..6401d4a8 100644 --- a/test/go/DataTypeMapStringFloat.go +++ b/test/go/DataTypeMapStringFloat.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/DataTypeMapStringInt.go b/test/go/DataTypeMapStringInt.go index 8df2aa8f..ae797a30 100644 --- a/test/go/DataTypeMapStringInt.go +++ b/test/go/DataTypeMapStringInt.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/DataTypeMapStringString.go b/test/go/DataTypeMapStringString.go index 40c77d40..9838fd66 100644 --- a/test/go/DataTypeMapStringString.go +++ b/test/go/DataTypeMapStringString.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/DataTypeSetFloat.go b/test/go/DataTypeSetFloat.go index cba92098..9d8ee728 100644 --- a/test/go/DataTypeSetFloat.go +++ b/test/go/DataTypeSetFloat.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/DataTypeSetInt.go b/test/go/DataTypeSetInt.go index 0ee45e23..f8467d50 100644 --- a/test/go/DataTypeSetInt.go +++ b/test/go/DataTypeSetInt.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/DataTypeSetString.go b/test/go/DataTypeSetString.go index 13c797aa..c34d74b5 100644 --- a/test/go/DataTypeSetString.go +++ b/test/go/DataTypeSetString.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/DataTypeString.go b/test/go/DataTypeString.go index f493d27b..4aa407e8 100644 --- a/test/go/DataTypeString.go +++ b/test/go/DataTypeString.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/LengthString.go b/test/go/LengthString.go index 1a6d77d9..12ad0ebf 100644 --- a/test/go/LengthString.go +++ b/test/go/LengthString.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/MultiAttribute.go b/test/go/MultiAttribute.go index a48265cf..418a8b55 100644 --- a/test/go/MultiAttribute.go +++ b/test/go/MultiAttribute.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/RangeSearchInt.go b/test/go/RangeSearchInt.go index c6b5726e..4bb2001b 100644 --- a/test/go/RangeSearchInt.go +++ b/test/go/RangeSearchInt.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/RangeSearchString.go b/test/go/RangeSearchString.go index 20e31cbc..75531373 100644 --- a/test/go/RangeSearchString.go +++ b/test/go/RangeSearchString.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/go/RegexSearch.go b/test/go/RegexSearch.go index 0cabf4c6..b9e53001 100644 --- a/test/go/RegexSearch.go +++ b/test/go/RegexSearch.go @@ -12,40 +12,40 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } for key, lval := range lhs { if rval, ok := rhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } } for key, rval := range rhs { if lval, ok := lhs[key]; ok { - lstr := fmt.Sprintln(lval) - rstr := fmt.Sprintln(rval) - for i := 0; i < 1000; i++ { - if lstr != rstr { - rstr = fmt.Sprintln(rval) - } - } - lmap, lok := lval.(client.Map) - rmap, rok := rval.(client.Map) + lstr := fmt.Sprintln(lval) + rstr := fmt.Sprintln(rval) + for i := 0; i < 1000; i++ { + if lstr != rstr { + rstr = fmt.Sprintln(rval) + } + } + lmap, lok := lval.(client.Map) + rmap, rok := rval.(client.Map) if !(lval == rval || reflect.DeepEqual(lval, rval) || - (lok && rok && sloppyEqualMap(lmap, rmap)) || - lstr == rstr) { + (lok && rok && sloppyEqualMap(lmap, rmap)) || + lstr == rstr) { return false - } + } } else { return false } @@ -54,27 +54,27 @@ func sloppyEqual(lhs map[interface{}]interface{}, rhs map[interface{}]interface{ } func sloppyEqualMap(lhs client.Map, rhs client.Map) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func sloppyEqualAttributes(lhs client.Attributes, rhs client.Attributes) bool { - lmap := map[interface{}]interface{}{} - rmap := map[interface{}]interface{}{} - for k, v := range lhs { - lmap[k] = v - } - for k, v := range rhs { - rmap[k] = v - } - return sloppyEqual(lmap, rmap) + lmap := map[interface{}]interface{}{} + rmap := map[interface{}]interface{}{} + for k, v := range lhs { + lmap[k] = v + } + for k, v := range rhs { + rmap[k] = v + } + return sloppyEqual(lmap, rmap) } func main() { diff --git a/test/rust/Basic.rs b/test/rust/Basic.rs new file mode 100644 index 00000000..215893ff --- /dev/null +++ b/test/rust/Basic.rs @@ -0,0 +1,197 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.get(r"kv", r"k") { + Ok(obj) => { + panic!("this object should not be found!"); + }, + Err(err) => (), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", r"v1",)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", r"v1",); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", r"v2",)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", r"v2",); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", r"v3",)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", r"v3",); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.del(r"kv", r"k") { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.get(r"kv", r"k") { + Ok(obj) => { + panic!("this object should not be found!"); + }, + Err(err) => (), + } + } diff --git a/test/rust/BasicSearch.rs b/test/rust/BasicSearch.rs new file mode 100644 index 00000000..616fa405 --- /dev/null +++ b/test/rust/BasicSearch.rs @@ -0,0 +1,155 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"v", EQUALS, r"v1"))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), BTreeSet::>::new().len()); + + match client.put(r"kv", r"k1", NewHyperObject!(r"v", r"v1",)) { + Ok(()) => (), + Err(err) => panic!(err), + } + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"v", EQUALS, r"v1"))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"k1", r"v", r"v1",)).len()); + + match client.put(r"kv", r"k2", NewHyperObject!(r"v", r"v1",)) { + Ok(()) => (), + Err(err) => panic!(err), + } + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"v", EQUALS, r"v1"))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"k1", r"v", r"v1",), NewHyperObject!(r"k", r"k2", r"v", r"v1",)).len()); + } diff --git a/test/rust/CondPut.rs b/test/rust/CondPut.rs new file mode 100644 index 00000000..14d35468 --- /dev/null +++ b/test/rust/CondPut.rs @@ -0,0 +1,185 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.get(r"kv", r"k") { + Ok(obj) => { + panic!("this object should not be found!"); + }, + Err(err) => (), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", r"v1",)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", r"v1",); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.cond_put(r"kv", r"k", vec!(HyperPredicate::new(r"v", EQUALS, r"v2")), NewHyperObject!(r"v", r"v3",)) { + Ok(()) => panic!("this CONDPUT operation should have failed"), + Err(err) => (), + } + let expected = NewHyperObject!(r"v", r"v1",); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.cond_put(r"kv", r"k", vec!(HyperPredicate::new(r"v", EQUALS, r"v1")), NewHyperObject!(r"v", r"v3",)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", r"v3",); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/DataTypeFloat.rs b/test/rust/DataTypeFloat.rs new file mode 100644 index 00000000..46bbbd00 --- /dev/null +++ b/test/rust/DataTypeFloat.rs @@ -0,0 +1,163 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"k", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", 0.0 as f64,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", 3.14 as f64,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", 3.14 as f64,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/DataTypeInt.rs b/test/rust/DataTypeInt.rs new file mode 100644 index 00000000..6361c67d --- /dev/null +++ b/test/rust/DataTypeInt.rs @@ -0,0 +1,223 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"k", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", 0 as i64,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", 1 as i64,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", 1 as i64,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", -1 as i64,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", -1 as i64,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", 0 as i64,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", 0 as i64,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", 9223372036854775807 as i64,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", 9223372036854775807 as i64,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", -9223372036854775808 as i64,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", -9223372036854775808 as i64,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/DataTypeListFloat.rs b/test/rust/DataTypeListFloat.rs new file mode 100644 index 00000000..8846e8ef --- /dev/null +++ b/test/rust/DataTypeListFloat.rs @@ -0,0 +1,178 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"k", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", Vec::::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", vec!(3.14 as f64, 0.25 as f64, 1.0 as f64),)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", vec!(3.14 as f64, 0.25 as f64, 1.0 as f64),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", Vec::::new(),)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", Vec::::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/DataTypeListInt.rs b/test/rust/DataTypeListInt.rs new file mode 100644 index 00000000..698fa03e --- /dev/null +++ b/test/rust/DataTypeListInt.rs @@ -0,0 +1,178 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"k", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", Vec::::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", vec!(1 as i64, 2 as i64, 3 as i64),)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", vec!(1 as i64, 2 as i64, 3 as i64),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", Vec::::new(),)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", Vec::::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/DataTypeListString.rs b/test/rust/DataTypeListString.rs new file mode 100644 index 00000000..b9e3d9da --- /dev/null +++ b/test/rust/DataTypeListString.rs @@ -0,0 +1,178 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"k", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", Vec::::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", vec!(r"A", r"B", r"C"),)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", vec!(r"A", r"B", r"C"),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", Vec::::new(),)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", Vec::::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/DataTypeMapFloatFloat.rs b/test/rust/DataTypeMapFloatFloat.rs new file mode 100644 index 00000000..0e0ff822 --- /dev/null +++ b/test/rust/DataTypeMapFloatFloat.rs @@ -0,0 +1,192 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"k", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", HashMap::, Vec>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", { +let mut m = HashMap::new(); +m.insert(F64(0.25 as f64), 2.0 as f64); +m.insert(F64(1.0 as f64), 3.0 as f64); +m.insert(F64(3.14 as f64), 1.0 as f64); +m +} +,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", { +let mut m = HashMap::new(); +m.insert(F64(0.25 as f64), 2.0 as f64); +m.insert(F64(1.0 as f64), 3.0 as f64); +m.insert(F64(3.14 as f64), 1.0 as f64); +m +} +,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", HashMap::, Vec>::new(),)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", HashMap::, Vec>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/DataTypeMapFloatInt.rs b/test/rust/DataTypeMapFloatInt.rs new file mode 100644 index 00000000..6275d6c8 --- /dev/null +++ b/test/rust/DataTypeMapFloatInt.rs @@ -0,0 +1,192 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"k", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", HashMap::, Vec>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", { +let mut m = HashMap::new(); +m.insert(F64(0.25 as f64), 2 as i64); +m.insert(F64(1.0 as f64), 3 as i64); +m.insert(F64(3.14 as f64), 1 as i64); +m +} +,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", { +let mut m = HashMap::new(); +m.insert(F64(0.25 as f64), 2 as i64); +m.insert(F64(1.0 as f64), 3 as i64); +m.insert(F64(3.14 as f64), 1 as i64); +m +} +,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", HashMap::, Vec>::new(),)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", HashMap::, Vec>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/DataTypeMapFloatString.rs b/test/rust/DataTypeMapFloatString.rs new file mode 100644 index 00000000..1cadaf48 --- /dev/null +++ b/test/rust/DataTypeMapFloatString.rs @@ -0,0 +1,192 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"k", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", HashMap::, Vec>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", { +let mut m = HashMap::new(); +m.insert(F64(0.25 as f64), r"Y"); +m.insert(F64(1.0 as f64), r"Z"); +m.insert(F64(3.14 as f64), r"X"); +m +} +,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", { +let mut m = HashMap::new(); +m.insert(F64(0.25 as f64), r"Y"); +m.insert(F64(1.0 as f64), r"Z"); +m.insert(F64(3.14 as f64), r"X"); +m +} +,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", HashMap::, Vec>::new(),)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", HashMap::, Vec>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/DataTypeMapIntFloat.rs b/test/rust/DataTypeMapIntFloat.rs new file mode 100644 index 00000000..5f1db0cb --- /dev/null +++ b/test/rust/DataTypeMapIntFloat.rs @@ -0,0 +1,192 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"k", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", HashMap::, Vec>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", { +let mut m = HashMap::new(); +m.insert(1 as i64, 3.14 as f64); +m.insert(2 as i64, 0.25 as f64); +m.insert(3 as i64, 1.0 as f64); +m +} +,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", { +let mut m = HashMap::new(); +m.insert(1 as i64, 3.14 as f64); +m.insert(2 as i64, 0.25 as f64); +m.insert(3 as i64, 1.0 as f64); +m +} +,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", HashMap::, Vec>::new(),)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", HashMap::, Vec>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/DataTypeMapIntInt.rs b/test/rust/DataTypeMapIntInt.rs new file mode 100644 index 00000000..b0a46700 --- /dev/null +++ b/test/rust/DataTypeMapIntInt.rs @@ -0,0 +1,192 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"k", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", HashMap::, Vec>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", { +let mut m = HashMap::new(); +m.insert(1 as i64, 7 as i64); +m.insert(2 as i64, 8 as i64); +m.insert(3 as i64, 9 as i64); +m +} +,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", { +let mut m = HashMap::new(); +m.insert(1 as i64, 7 as i64); +m.insert(2 as i64, 8 as i64); +m.insert(3 as i64, 9 as i64); +m +} +,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", HashMap::, Vec>::new(),)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", HashMap::, Vec>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/DataTypeMapIntString.rs b/test/rust/DataTypeMapIntString.rs new file mode 100644 index 00000000..dcc8381b --- /dev/null +++ b/test/rust/DataTypeMapIntString.rs @@ -0,0 +1,192 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"k", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", HashMap::, Vec>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", { +let mut m = HashMap::new(); +m.insert(1 as i64, r"X"); +m.insert(2 as i64, r"Y"); +m.insert(3 as i64, r"Z"); +m +} +,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", { +let mut m = HashMap::new(); +m.insert(1 as i64, r"X"); +m.insert(2 as i64, r"Y"); +m.insert(3 as i64, r"Z"); +m +} +,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", HashMap::, Vec>::new(),)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", HashMap::, Vec>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/DataTypeMapStringFloat.rs b/test/rust/DataTypeMapStringFloat.rs new file mode 100644 index 00000000..d9c16eea --- /dev/null +++ b/test/rust/DataTypeMapStringFloat.rs @@ -0,0 +1,192 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"k", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", HashMap::, Vec>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", { +let mut m = HashMap::new(); +m.insert(r"A", 3.14 as f64); +m.insert(r"C", 1.0 as f64); +m.insert(r"B", 0.25 as f64); +m +} +,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", { +let mut m = HashMap::new(); +m.insert(r"A", 3.14 as f64); +m.insert(r"C", 1.0 as f64); +m.insert(r"B", 0.25 as f64); +m +} +,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", HashMap::, Vec>::new(),)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", HashMap::, Vec>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/DataTypeMapStringInt.rs b/test/rust/DataTypeMapStringInt.rs new file mode 100644 index 00000000..c2e2322a --- /dev/null +++ b/test/rust/DataTypeMapStringInt.rs @@ -0,0 +1,192 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"k", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", HashMap::, Vec>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", { +let mut m = HashMap::new(); +m.insert(r"A", 1 as i64); +m.insert(r"C", 3 as i64); +m.insert(r"B", 2 as i64); +m +} +,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", { +let mut m = HashMap::new(); +m.insert(r"A", 1 as i64); +m.insert(r"C", 3 as i64); +m.insert(r"B", 2 as i64); +m +} +,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", HashMap::, Vec>::new(),)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", HashMap::, Vec>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/DataTypeMapStringString.rs b/test/rust/DataTypeMapStringString.rs new file mode 100644 index 00000000..d0db1d0c --- /dev/null +++ b/test/rust/DataTypeMapStringString.rs @@ -0,0 +1,192 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"k", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", HashMap::, Vec>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", { +let mut m = HashMap::new(); +m.insert(r"A", r"X"); +m.insert(r"C", r"Z"); +m.insert(r"B", r"Y"); +m +} +,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", { +let mut m = HashMap::new(); +m.insert(r"A", r"X"); +m.insert(r"C", r"Z"); +m.insert(r"B", r"Y"); +m +} +,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", HashMap::, Vec>::new(),)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", HashMap::, Vec>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/DataTypeSetFloat.rs b/test/rust/DataTypeSetFloat.rs new file mode 100644 index 00000000..b929a6de --- /dev/null +++ b/test/rust/DataTypeSetFloat.rs @@ -0,0 +1,192 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"k", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", BTreeSet::>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", { +let mut s = BTreeSet::new(); +s.insert(F64(0.25 as f64)); +s.insert(F64(1.0 as f64)); +s.insert(F64(3.14 as f64)); +s +} +,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", { +let mut s = BTreeSet::new(); +s.insert(F64(0.25 as f64)); +s.insert(F64(1.0 as f64)); +s.insert(F64(3.14 as f64)); +s +} +,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", BTreeSet::>::new(),)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", BTreeSet::>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/DataTypeSetInt.rs b/test/rust/DataTypeSetInt.rs new file mode 100644 index 00000000..d22dccca --- /dev/null +++ b/test/rust/DataTypeSetInt.rs @@ -0,0 +1,192 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"k", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", BTreeSet::>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", { +let mut s = BTreeSet::new(); +s.insert(1 as i64); +s.insert(2 as i64); +s.insert(3 as i64); +s +} +,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", { +let mut s = BTreeSet::new(); +s.insert(1 as i64); +s.insert(2 as i64); +s.insert(3 as i64); +s +} +,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", BTreeSet::>::new(),)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", BTreeSet::>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/DataTypeSetString.rs b/test/rust/DataTypeSetString.rs new file mode 100644 index 00000000..9683a7cb --- /dev/null +++ b/test/rust/DataTypeSetString.rs @@ -0,0 +1,192 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"k", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", BTreeSet::>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", { +let mut s = BTreeSet::new(); +s.insert(r"A"); +s.insert(r"C"); +s.insert(r"B"); +s +} +,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", { +let mut s = BTreeSet::new(); +s.insert(r"A"); +s.insert(r"C"); +s.insert(r"B"); +s +} +,); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", BTreeSet::>::new(),)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", BTreeSet::>::new(),); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/DataTypeString.rs b/test/rust/DataTypeString.rs new file mode 100644 index 00000000..ae1a8945 --- /dev/null +++ b/test/rust/DataTypeString.rs @@ -0,0 +1,178 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"k", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", r"",); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", r"xxx",)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", r"xxx",); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v", r"\xde\xad\xbe\xef",)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v", r"\xde\xad\xbe\xef",); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/LengthString.rs b/test/rust/LengthString.rs new file mode 100644 index 00000000..4133ea22 --- /dev/null +++ b/test/rust/LengthString.rs @@ -0,0 +1,186 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"A", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"AB", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"ABC", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"ABCD", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"ABCDE", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", LENGTH_EQUALS, 1 as i64))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"A",)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", LENGTH_EQUALS, 2 as i64))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"AB",)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", LENGTH_EQUALS, 3 as i64))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"ABC",)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", LENGTH_EQUALS, 4 as i64))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"ABCD",)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", LENGTH_EQUALS, 5 as i64))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"ABCDE",)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", LENGTH_LESS_EQUAL, 3 as i64))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"A",), NewHyperObject!(r"k", r"AB",), NewHyperObject!(r"k", r"ABC",)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", LENGTH_GREATER_EQUAL, 3 as i64))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"ABC",), NewHyperObject!(r"k", r"ABCD",), NewHyperObject!(r"k", r"ABCDE",)).len()); + } diff --git a/test/rust/MultiAttribute.rs b/test/rust/MultiAttribute.rs new file mode 100644 index 00000000..2395ac35 --- /dev/null +++ b/test/rust/MultiAttribute.rs @@ -0,0 +1,180 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.get(r"kv", r"k") { + Ok(obj) => { + panic!("this object should not be found!"); + }, + Err(err) => (), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v1", r"ABC",)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v1", r"ABC", r"v2", r"",); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + + match client.put(r"kv", r"k", NewHyperObject!(r"v2", r"123",)) { + Ok(()) => (), + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v1", r"ABC", r"v2", r"123",); + match client.get(r"kv", r"k") { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + let expected = NewHyperObject!(r"v1", r"ABC",); + match client.get_partial(r"kv", r"k", vec!(r"v1")) { + Ok(obj) => { + if !sloppyCompareHyper(&obj, &expected) { + panic!("expected: {:?} +actual: {:?}", expected, obj); + } + }, + Err(err) => panic!(err), + } + } diff --git a/test/rust/RangeSearchInt.rs b/test/rust/RangeSearchInt.rs new file mode 100644 index 00000000..bb701cf5 --- /dev/null +++ b/test/rust/RangeSearchInt.rs @@ -0,0 +1,198 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", -2 as i64, NewHyperObject!(r"v", -2 as i64,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", -1 as i64, NewHyperObject!(r"v", -1 as i64,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", 0 as i64, NewHyperObject!(r"v", 0 as i64,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", 1 as i64, NewHyperObject!(r"v", 1 as i64,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", 2 as i64, NewHyperObject!(r"v", 2 as i64,)) { + Ok(()) => (), + Err(err) => panic!(err), + } + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", LESS_EQUAL, 0 as i64))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", -2 as i64, r"v", -2 as i64,), NewHyperObject!(r"k", -1 as i64, r"v", -1 as i64,), NewHyperObject!(r"k", 0 as i64, r"v", 0 as i64,)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"v", LESS_EQUAL, 0 as i64))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", -2 as i64, r"v", -2 as i64,), NewHyperObject!(r"k", -1 as i64, r"v", -1 as i64,), NewHyperObject!(r"k", 0 as i64, r"v", 0 as i64,)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", GREATER_EQUAL, 0 as i64))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", 0 as i64, r"v", 0 as i64,), NewHyperObject!(r"k", 1 as i64, r"v", 1 as i64,), NewHyperObject!(r"k", 2 as i64, r"v", 2 as i64,)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"v", GREATER_EQUAL, 0 as i64))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", 0 as i64, r"v", 0 as i64,), NewHyperObject!(r"k", 1 as i64, r"v", 1 as i64,), NewHyperObject!(r"k", 2 as i64, r"v", 2 as i64,)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", LESS_THAN, 0 as i64))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", -2 as i64, r"v", -2 as i64,), NewHyperObject!(r"k", -1 as i64, r"v", -1 as i64,)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"v", LESS_THAN, 0 as i64))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", -2 as i64, r"v", -2 as i64,), NewHyperObject!(r"k", -1 as i64, r"v", -1 as i64,)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", GREATER_THAN, 0 as i64))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", 1 as i64, r"v", 1 as i64,), NewHyperObject!(r"k", 2 as i64, r"v", 2 as i64,)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"v", GREATER_THAN, 0 as i64))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", 1 as i64, r"v", 1 as i64,), NewHyperObject!(r"k", 2 as i64, r"v", 2 as i64,)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", GREATER_EQUAL, -1 as i64), HyperPredicate::new(r"k", LESS_EQUAL, 1 as i64))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", -1 as i64, r"v", -1 as i64,), NewHyperObject!(r"k", 0 as i64, r"v", 0 as i64,), NewHyperObject!(r"k", 1 as i64, r"v", 1 as i64,)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"v", GREATER_EQUAL, -1 as i64), HyperPredicate::new(r"v", LESS_EQUAL, 1 as i64))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", -1 as i64, r"v", -1 as i64,), NewHyperObject!(r"k", 0 as i64, r"v", 0 as i64,), NewHyperObject!(r"k", 1 as i64, r"v", 1 as i64,)).len()); + } diff --git a/test/rust/RangeSearchString.rs b/test/rust/RangeSearchString.rs new file mode 100644 index 00000000..0afe86fd --- /dev/null +++ b/test/rust/RangeSearchString.rs @@ -0,0 +1,198 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"A", NewHyperObject!(r"v", r"A",)) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"B", NewHyperObject!(r"v", r"B",)) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"C", NewHyperObject!(r"v", r"C",)) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"D", NewHyperObject!(r"v", r"D",)) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"E", NewHyperObject!(r"v", r"E",)) { + Ok(()) => (), + Err(err) => panic!(err), + } + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", LESS_EQUAL, r"C"))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"A", r"v", r"A",), NewHyperObject!(r"k", r"B", r"v", r"B",), NewHyperObject!(r"k", r"C", r"v", r"C",)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"v", LESS_EQUAL, r"C"))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"A", r"v", r"A",), NewHyperObject!(r"k", r"B", r"v", r"B",), NewHyperObject!(r"k", r"C", r"v", r"C",)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", GREATER_EQUAL, r"C"))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"C", r"v", r"C",), NewHyperObject!(r"k", r"D", r"v", r"D",), NewHyperObject!(r"k", r"E", r"v", r"E",)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"v", GREATER_EQUAL, r"C"))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"C", r"v", r"C",), NewHyperObject!(r"k", r"D", r"v", r"D",), NewHyperObject!(r"k", r"E", r"v", r"E",)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", LESS_THAN, r"C"))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"A", r"v", r"A",), NewHyperObject!(r"k", r"B", r"v", r"B",)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"v", LESS_THAN, r"C"))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"A", r"v", r"A",), NewHyperObject!(r"k", r"B", r"v", r"B",)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", GREATER_THAN, r"C"))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"D", r"v", r"D",), NewHyperObject!(r"k", r"E", r"v", r"E",)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"v", GREATER_THAN, r"C"))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"D", r"v", r"D",), NewHyperObject!(r"k", r"E", r"v", r"E",)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", GREATER_EQUAL, r"B"), HyperPredicate::new(r"k", LESS_EQUAL, r"D"))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"B", r"v", r"B",), NewHyperObject!(r"k", r"C", r"v", r"C",), NewHyperObject!(r"k", r"D", r"v", r"D",)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"v", GREATER_EQUAL, r"B"), HyperPredicate::new(r"v", LESS_EQUAL, r"D"))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"B", r"v", r"B",), NewHyperObject!(r"k", r"C", r"v", r"C",), NewHyperObject!(r"k", r"D", r"v", r"D",)).len()); + } diff --git a/test/rust/RegexSearch.rs b/test/rust/RegexSearch.rs new file mode 100644 index 00000000..5fa96728 --- /dev/null +++ b/test/rust/RegexSearch.rs @@ -0,0 +1,280 @@ + +#![feature(convert)] +#[macro_use] extern crate hyperdex; + +use std::os; +use std::str::FromStr; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::iter::FromIterator; +use std::mem::transmute; +use std::any::Any; + +use hyperdex::*; +use hyperdex::HyperValue::*; +use hyperdex::HyperPredicateType::*; + +macro_rules! sloppyCompare { + ($a: ident, $b: ident) => ( + if $a.len() == 0 && $b.len() == 0 { + true + } else { + false + } + ); +} + +fn sloppyCompareHyper(a: &HyperObject, b: &HyperObject) -> bool { + for (ak, av) in a.map.iter() { + let bv = match b.map.get(ak) { + None => return false, + Some(x) => x, + }; + + let av = av.clone(); + let bv = bv.clone(); + + // this is dumb but I do not see a better way... fortunately the following lines are generated + // by a python script + match (av, bv) { + (HyperListString(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListString(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListInt(x), HyperListFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperListFloat(x), HyperListInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetString(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetInt(x), HyperSetFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperSetFloat(x), HyperSetInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapStringFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapIntFloat(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatString(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatInt(x), HyperMapFloatFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapStringFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapIntFloat(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatString(y)) => if !sloppyCompare!(x, y) { return false; }, + (HyperMapFloatFloat(x), HyperMapFloatInt(y)) => if !sloppyCompare!(x, y) { return false; }, + (x, y) => if x != y { return false; }, + } + } + return true; +} + +fn main() { + let args: Vec = std::env::args().collect(); + let mut client = Client::new(FromStr::from_str(format!("{}:{}", args[1], args[2]).as_str()).unwrap()).unwrap(); + + match client.put(r"kv", r"foo/foo/foo", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"foo/foo/bar", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"foo/foo/baz", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"foo/bar/foo", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"foo/bar/bar", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"foo/bar/baz", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"foo/baz/foo", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"foo/baz/bar", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"foo/baz/baz", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"bar/foo/foo", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"bar/foo/bar", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"bar/foo/baz", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"bar/bar/foo", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"bar/bar/bar", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"bar/bar/baz", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"bar/baz/foo", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"bar/baz/bar", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"bar/baz/baz", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"baz/foo/foo", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"baz/foo/bar", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"baz/foo/baz", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"baz/bar/foo", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"baz/bar/bar", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"baz/bar/baz", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"baz/baz/foo", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"baz/baz/bar", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + match client.put(r"kv", r"baz/baz/baz", HyperObject::new()) { + Ok(()) => (), + Err(err) => panic!(err), + } + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", REGEX, r"^foo"))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"foo/foo/foo",), NewHyperObject!(r"k", r"foo/foo/bar",), NewHyperObject!(r"k", r"foo/foo/baz",), NewHyperObject!(r"k", r"foo/bar/foo",), NewHyperObject!(r"k", r"foo/bar/bar",), NewHyperObject!(r"k", r"foo/bar/baz",), NewHyperObject!(r"k", r"foo/baz/foo",), NewHyperObject!(r"k", r"foo/baz/bar",), NewHyperObject!(r"k", r"foo/baz/baz",)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", REGEX, r"foo$"))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"foo/foo/foo",), NewHyperObject!(r"k", r"foo/bar/foo",), NewHyperObject!(r"k", r"foo/baz/foo",), NewHyperObject!(r"k", r"bar/foo/foo",), NewHyperObject!(r"k", r"bar/bar/foo",), NewHyperObject!(r"k", r"bar/baz/foo",), NewHyperObject!(r"k", r"baz/foo/foo",), NewHyperObject!(r"k", r"baz/bar/foo",), NewHyperObject!(r"k", r"baz/baz/foo",)).len()); + + let res = client.search(r"kv", vec!(HyperPredicate::new(r"k", REGEX, r"^b.*/foo/.*$"))); + let elems: Vec> = res.iter().collect(); + assert_eq!(elems.len(), vec!(NewHyperObject!(r"k", r"bar/foo/foo",), NewHyperObject!(r"k", r"bar/foo/bar",), NewHyperObject!(r"k", r"bar/foo/baz",), NewHyperObject!(r"k", r"baz/foo/foo",), NewHyperObject!(r"k", r"baz/foo/bar",), NewHyperObject!(r"k", r"baz/foo/baz",)).len()); + } diff --git a/test/sh/bindings.rust.Basic.sh b/test/sh/bindings.rust.Basic.sh new file mode 100755 index 00000000..c5857270 --- /dev/null +++ b/test/sh/bindings.rust.Basic.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/Basic "${HYPERDEX_SRCDIR}"/test/rust/Basic.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attribute v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/Basic {HOST} {PORT} diff --git a/test/sh/bindings.rust.BasicSearch.sh b/test/sh/bindings.rust.BasicSearch.sh new file mode 100755 index 00000000..663ae041 --- /dev/null +++ b/test/sh/bindings.rust.BasicSearch.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/BasicSearch "${HYPERDEX_SRCDIR}"/test/rust/BasicSearch.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attribute v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/BasicSearch {HOST} {PORT} diff --git a/test/sh/bindings.rust.CondPut.sh b/test/sh/bindings.rust.CondPut.sh new file mode 100755 index 00000000..d87e8642 --- /dev/null +++ b/test/sh/bindings.rust.CondPut.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/CondPut "${HYPERDEX_SRCDIR}"/test/rust/CondPut.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attribute v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/CondPut {HOST} {PORT} diff --git a/test/sh/bindings.rust.DataTypeFloat.sh b/test/sh/bindings.rust.DataTypeFloat.sh new file mode 100755 index 00000000..f2f0c39a --- /dev/null +++ b/test/sh/bindings.rust.DataTypeFloat.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeFloat "${HYPERDEX_SRCDIR}"/test/rust/DataTypeFloat.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attributes float v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeFloat {HOST} {PORT} diff --git a/test/sh/bindings.rust.DataTypeInt.sh b/test/sh/bindings.rust.DataTypeInt.sh new file mode 100755 index 00000000..22cee793 --- /dev/null +++ b/test/sh/bindings.rust.DataTypeInt.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeInt "${HYPERDEX_SRCDIR}"/test/rust/DataTypeInt.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attributes int v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeInt {HOST} {PORT} diff --git a/test/sh/bindings.rust.DataTypeListFloat.sh b/test/sh/bindings.rust.DataTypeListFloat.sh new file mode 100755 index 00000000..c694c4b7 --- /dev/null +++ b/test/sh/bindings.rust.DataTypeListFloat.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeListFloat "${HYPERDEX_SRCDIR}"/test/rust/DataTypeListFloat.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attributes list(float) v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeListFloat {HOST} {PORT} diff --git a/test/sh/bindings.rust.DataTypeListInt.sh b/test/sh/bindings.rust.DataTypeListInt.sh new file mode 100755 index 00000000..46f4a88a --- /dev/null +++ b/test/sh/bindings.rust.DataTypeListInt.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeListInt "${HYPERDEX_SRCDIR}"/test/rust/DataTypeListInt.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attributes list(int) v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeListInt {HOST} {PORT} diff --git a/test/sh/bindings.rust.DataTypeListString.sh b/test/sh/bindings.rust.DataTypeListString.sh new file mode 100755 index 00000000..190e9a36 --- /dev/null +++ b/test/sh/bindings.rust.DataTypeListString.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeListString "${HYPERDEX_SRCDIR}"/test/rust/DataTypeListString.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attributes list(string) v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeListString {HOST} {PORT} diff --git a/test/sh/bindings.rust.DataTypeMapFloatFloat.sh b/test/sh/bindings.rust.DataTypeMapFloatFloat.sh new file mode 100755 index 00000000..53f5bbf2 --- /dev/null +++ b/test/sh/bindings.rust.DataTypeMapFloatFloat.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeMapFloatFloat "${HYPERDEX_SRCDIR}"/test/rust/DataTypeMapFloatFloat.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attributes map(float, float) v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeMapFloatFloat {HOST} {PORT} diff --git a/test/sh/bindings.rust.DataTypeMapFloatInt.sh b/test/sh/bindings.rust.DataTypeMapFloatInt.sh new file mode 100755 index 00000000..f32995d9 --- /dev/null +++ b/test/sh/bindings.rust.DataTypeMapFloatInt.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeMapFloatInt "${HYPERDEX_SRCDIR}"/test/rust/DataTypeMapFloatInt.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attributes map(float, int) v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeMapFloatInt {HOST} {PORT} diff --git a/test/sh/bindings.rust.DataTypeMapFloatString.sh b/test/sh/bindings.rust.DataTypeMapFloatString.sh new file mode 100755 index 00000000..a1aab8de --- /dev/null +++ b/test/sh/bindings.rust.DataTypeMapFloatString.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeMapFloatString "${HYPERDEX_SRCDIR}"/test/rust/DataTypeMapFloatString.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attributes map(float, string) v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeMapFloatString {HOST} {PORT} diff --git a/test/sh/bindings.rust.DataTypeMapIntFloat.sh b/test/sh/bindings.rust.DataTypeMapIntFloat.sh new file mode 100755 index 00000000..2b02c98a --- /dev/null +++ b/test/sh/bindings.rust.DataTypeMapIntFloat.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeMapIntFloat "${HYPERDEX_SRCDIR}"/test/rust/DataTypeMapIntFloat.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attributes map(int, float) v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeMapIntFloat {HOST} {PORT} diff --git a/test/sh/bindings.rust.DataTypeMapIntInt.sh b/test/sh/bindings.rust.DataTypeMapIntInt.sh new file mode 100755 index 00000000..92bc2725 --- /dev/null +++ b/test/sh/bindings.rust.DataTypeMapIntInt.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeMapIntInt "${HYPERDEX_SRCDIR}"/test/rust/DataTypeMapIntInt.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attributes map(int, int) v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeMapIntInt {HOST} {PORT} diff --git a/test/sh/bindings.rust.DataTypeMapIntString.sh b/test/sh/bindings.rust.DataTypeMapIntString.sh new file mode 100755 index 00000000..61b1bfcc --- /dev/null +++ b/test/sh/bindings.rust.DataTypeMapIntString.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeMapIntString "${HYPERDEX_SRCDIR}"/test/rust/DataTypeMapIntString.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attributes map(int, string) v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeMapIntString {HOST} {PORT} diff --git a/test/sh/bindings.rust.DataTypeMapStringFloat.sh b/test/sh/bindings.rust.DataTypeMapStringFloat.sh new file mode 100755 index 00000000..928770b6 --- /dev/null +++ b/test/sh/bindings.rust.DataTypeMapStringFloat.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeMapStringFloat "${HYPERDEX_SRCDIR}"/test/rust/DataTypeMapStringFloat.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attributes map(string, float) v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeMapStringFloat {HOST} {PORT} diff --git a/test/sh/bindings.rust.DataTypeMapStringInt.sh b/test/sh/bindings.rust.DataTypeMapStringInt.sh new file mode 100755 index 00000000..324ed020 --- /dev/null +++ b/test/sh/bindings.rust.DataTypeMapStringInt.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeMapStringInt "${HYPERDEX_SRCDIR}"/test/rust/DataTypeMapStringInt.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attributes map(string, int) v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeMapStringInt {HOST} {PORT} diff --git a/test/sh/bindings.rust.DataTypeMapStringString.sh b/test/sh/bindings.rust.DataTypeMapStringString.sh new file mode 100755 index 00000000..0973d73d --- /dev/null +++ b/test/sh/bindings.rust.DataTypeMapStringString.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeMapStringString "${HYPERDEX_SRCDIR}"/test/rust/DataTypeMapStringString.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attributes map(string, string) v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeMapStringString {HOST} {PORT} diff --git a/test/sh/bindings.rust.DataTypeSetFloat.sh b/test/sh/bindings.rust.DataTypeSetFloat.sh new file mode 100755 index 00000000..198044aa --- /dev/null +++ b/test/sh/bindings.rust.DataTypeSetFloat.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeSetFloat "${HYPERDEX_SRCDIR}"/test/rust/DataTypeSetFloat.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attributes set(float) v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeSetFloat {HOST} {PORT} diff --git a/test/sh/bindings.rust.DataTypeSetInt.sh b/test/sh/bindings.rust.DataTypeSetInt.sh new file mode 100755 index 00000000..ab9fa4fd --- /dev/null +++ b/test/sh/bindings.rust.DataTypeSetInt.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeSetInt "${HYPERDEX_SRCDIR}"/test/rust/DataTypeSetInt.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attributes set(int) v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeSetInt {HOST} {PORT} diff --git a/test/sh/bindings.rust.DataTypeSetString.sh b/test/sh/bindings.rust.DataTypeSetString.sh new file mode 100755 index 00000000..fcd8b22d --- /dev/null +++ b/test/sh/bindings.rust.DataTypeSetString.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeSetString "${HYPERDEX_SRCDIR}"/test/rust/DataTypeSetString.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attributes set(string) v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeSetString {HOST} {PORT} diff --git a/test/sh/bindings.rust.DataTypeString.sh b/test/sh/bindings.rust.DataTypeString.sh new file mode 100755 index 00000000..ddf6188d --- /dev/null +++ b/test/sh/bindings.rust.DataTypeString.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeString "${HYPERDEX_SRCDIR}"/test/rust/DataTypeString.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attributes v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/DataTypeString {HOST} {PORT} diff --git a/test/sh/bindings.rust.LengthString.sh b/test/sh/bindings.rust.LengthString.sh new file mode 100755 index 00000000..9a04c0e4 --- /dev/null +++ b/test/sh/bindings.rust.LengthString.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/LengthString "${HYPERDEX_SRCDIR}"/test/rust/LengthString.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/LengthString {HOST} {PORT} diff --git a/test/sh/bindings.rust.MultiAttribute.sh b/test/sh/bindings.rust.MultiAttribute.sh new file mode 100755 index 00000000..4e952502 --- /dev/null +++ b/test/sh/bindings.rust.MultiAttribute.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/MultiAttribute "${HYPERDEX_SRCDIR}"/test/rust/MultiAttribute.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attributes v1, v2" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/MultiAttribute {HOST} {PORT} diff --git a/test/sh/bindings.rust.RangeSearchInt.sh b/test/sh/bindings.rust.RangeSearchInt.sh new file mode 100755 index 00000000..5852d5ec --- /dev/null +++ b/test/sh/bindings.rust.RangeSearchInt.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/RangeSearchInt "${HYPERDEX_SRCDIR}"/test/rust/RangeSearchInt.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key int k attribute int v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/RangeSearchInt {HOST} {PORT} diff --git a/test/sh/bindings.rust.RangeSearchString.sh b/test/sh/bindings.rust.RangeSearchString.sh new file mode 100755 index 00000000..654c00c6 --- /dev/null +++ b/test/sh/bindings.rust.RangeSearchString.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/RangeSearchString "${HYPERDEX_SRCDIR}"/test/rust/RangeSearchString.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k attribute v" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/RangeSearchString {HOST} {PORT} diff --git a/test/sh/bindings.rust.RegexSearch.sh b/test/sh/bindings.rust.RegexSearch.sh new file mode 100755 index 00000000..cd90cc57 --- /dev/null +++ b/test/sh/bindings.rust.RegexSearch.sh @@ -0,0 +1,5 @@ +#!/bin/sh +rustc -g -L rust_hyperdex/target/debug -L rust_hyperdex/target/debug/deps -o "${HYPERDEX_BUILDDIR}"/test/rust/RegexSearch "${HYPERDEX_SRCDIR}"/test/rust/RegexSearch.rs + +python2 "${HYPERDEX_SRCDIR}"/test/runner.py --space="space kv key k" --daemons=1 -- \ + "${HYPERDEX_BUILDDIR}"/test/rust/RegexSearch {HOST} {PORT}