Branch: Tag:

2000-01-20

2000-01-20 23:12:01 by Fredrik Noring <noring@nocrew.org>

Added tests for has_index, has_value and search.

Rev: src/testsuite.in:1.262

1: - test_true([["$Id: testsuite.in,v 1.261 2000/01/19 17:57:05 mast Exp $"]]); + test_true([["$Id: testsuite.in,v 1.262 2000/01/20 23:12:01 noring Exp $"]]);      cond([[all_constants()->_verify_internals]],   [[
3725:   test_true(arrayp(rusage()))   test_true(sizeof(rusage())>0)    + // - has_index + test_false([[ has_index(({}), 0) ]]) + test_false([[ has_index(({}), "foo") ]]) + test_false([[ has_index(({ "a" }), -1) ]]) + test_false([[ has_index(({ "a" }), "a") ]]) + test_true([[ has_index(({ "a" }), 0) ]]) + test_false([[ has_index(({ "a" }), 1) ]]) + test_true([[ has_index(({ "a", "b" }), 1) ]]) + test_false([[ has_index(([ "a":"A" ]), 4711) ]]) + test_true([[ has_index(([ "a":"A" ]), "a") ]]) + test_false([[ has_index(([ "a":"A" ]), "A") ]]) + test_true([[ has_index(([ "a":"A", "b":"B", "c":"C" ]), "b") ]]) + test_false([[ has_index(([ "a":"A", "b":"B", "c":"C" ]), "B") ]]) + test_eval_error([[ has_index((class {})(), "foo") ]]) + test_true([[has_index((class{array _indices(){return({"a","b"});}})(),"b")]]) +  + // - has_value + test_false([[ has_value(({}), 0) ]]) + test_false([[ has_value(({}), "foo") ]]) + test_false([[ has_value(({ "a" }), -1) ]]) + test_true([[ has_value(({ "a" }), "a") ]]) + test_false([[ has_value(({ "a" }), 0) ]]) + test_true([[ has_value(({ "a", "b" }), "b") ]]) + test_false([[ has_value(([ "a":"A" ]), 4711) ]]) + test_true([[ has_value(([ "a":"A" ]), "A") ]]) + test_false([[ has_value(([ "a":"A" ]), "a") ]]) + test_true([[ has_value(([ "a":"A", "b":"B", "c":"C" ]), "B") ]]) + test_false([[ has_value(([ "a":"A", "b":"B", "c":"C" ]), "b") ]]) + test_eval_error([[ has_value((class {})(), "foo") ]]) + test_true([[has_value((class{array _values(){return({"a","b"});}})(),"b")]]) +    // - search   test_eval_error(return search("foolbar","o",-10))   test_eval_error(return search("foolbar","o",2983742))
3748:   test_eq(search(([1:2,3:4,5:6,7:8]),4),3)   test_true(zero_type(search(([1:2,3:4,5:6,7:8]),3)))   test_eq(search(([1:2,3:4,5:6,7:8]),8),7) + test_do([[ +  class C +  { +  mapping m;    -  +  int `==() +  { +  foreach(indices(m), mixed x) +  m_delete(m, x); +  return 0; +  } +  +  void create(mapping _m) +  { +  m = _m; +  } +  } +  +  mapping m = ([ ]); +  C o = C(m); +  +  for(int i = 0; i < 100; i++) +  m[i] = o; +  +  search(m, 4711); + ]]) +  +    // test large searches (find string, size, pattern)   define(test_search,[[   test_eq(sprintf($1+"%'"+$3+"'*n",$2)[..strlen($1)-1],$1)