Пример #1
0
  void test_initial_values(void)
  {
    grn::dat::Base base;

    cppcut_assert_equal(false, base.is_linker());
    cppcut_assert_equal(grn::dat::UInt32(0), base.offset());
  }
Пример #2
0
  void test_offset(void)
  {
    grn::dat::Trie trie;
    create_trie(&trie);

    grn::dat::PrefixCursor cursor;

    cursor.open(trie, grn::dat::String("東京都庁ビル"), 0, 0);
    cppcut_assert_equal(grn::dat::UInt32(1), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("東京都庁ビル"), 0, 1);
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("東京都庁ビル"), 0, 2);
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("東京都庁ビル"), 0, 3);
    cppcut_assert_equal(false, cursor.next().is_valid());
  }
Пример #3
0
  void test_ascending_cursor(void)
  {
    grn::dat::Trie trie;
    create_trie(&trie);

    grn::dat::PrefixCursor cursor;

    cursor.open(trie, grn::dat::String("京都府"), 0,
                0, grn::dat::UINT32_MAX, grn::dat::ASCENDING_CURSOR);
    cppcut_assert_equal(grn::dat::UInt32(2), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(4), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("京都府"), std::strlen("京都"),
                0, grn::dat::UINT32_MAX, grn::dat::ASCENDING_CURSOR);
    cppcut_assert_equal(grn::dat::UInt32(2), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(4), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("京都府"), 0,
                1, grn::dat::UINT32_MAX, grn::dat::ASCENDING_CURSOR);
    cppcut_assert_equal(grn::dat::UInt32(4), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("京都府"), 0,
                0, 1, grn::dat::ASCENDING_CURSOR);
    cppcut_assert_equal(grn::dat::UInt32(2), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());
  }
Пример #4
0
  void test_copy_with_length(void)
  {
    char buf[] = "This is a pen.";

    grn::dat::Array<char> clone(buf, sizeof(buf));
    cppcut_assert_equal(buf, clone.ptr());
    cppcut_assert_equal(sizeof(buf), static_cast<size_t>(clone.size()));
  }
Пример #5
0
  void test_nonlinker(void)
  {
    grn::dat::Base base;

    base.set_offset(1000);
    cppcut_assert_equal(false, base.is_linker());
    cppcut_assert_equal(grn::dat::UInt32(1000), base.offset());
  }
Пример #6
0
  void test_linker(void)
  {
    grn::dat::Base base;

    base.set_key_pos(100);
    cppcut_assert_equal(true, base.is_linker());
    cppcut_assert_equal(grn::dat::UInt32(100), base.key_pos());
  }
Пример #7
0
  void test_assign_without_length(void)
  {
    char buf[] = "This is a pen.";

    grn::dat::Array<char> array;

    array.assign(buf);
    cppcut_assert_equal(buf, array.ptr());
    cppcut_assert_equal(sizeof(buf), static_cast<size_t>(array.size()));
  }
Пример #8
0
  void test_unphantomize(void)
  {
    grn::dat::Check check;

    check.set_is_phantom(true);
    check.set_is_phantom(false);
    cppcut_assert_equal(false, check.is_phantom());
    cppcut_assert_equal(grn::dat::INVALID_LABEL, check.child());
    cppcut_assert_equal(grn::dat::INVALID_LABEL, check.sibling());
  }
Пример #9
0
  void test_min_max(void)
  {
    grn::dat::Trie trie;
    create_trie(&trie);

    grn::dat::KeyCursor cursor;
    cursor.open(trie, grn::dat::String("Gnome"), grn::dat::String("Trebor"));
    cppcut_assert_equal(grn::dat::UInt32(6), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(7), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(2), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());
  }
Пример #10
0
  void test_phantomize(void)
  {
    grn::dat::Check check;

    check.set_is_phantom(true);
    cppcut_assert_equal(true, check.is_phantom());
    cppcut_assert_equal(grn::dat::UInt32(0), check.next());
    cppcut_assert_equal(grn::dat::UInt32(0), check.prev());

    check.set_next(101);
    check.set_prev(99);
    cppcut_assert_equal(grn::dat::UInt32(101), check.next());
    cppcut_assert_equal(grn::dat::UInt32(99), check.prev());
  }
Пример #11
0
  void test_immutable_values(void)
  {
    grn::dat::Header header;

    header.set_file_size(10000);
    header.set_max_num_keys(30);
    header.set_max_num_blocks(20);
    header.set_key_buf_size(800);

    cppcut_assert_equal(grn::dat::UInt64(10000), header.file_size());
    cppcut_assert_equal(grn::dat::UInt32(30), header.max_num_keys());
    cppcut_assert_equal(grn::dat::BLOCK_SIZE * 20, header.max_num_nodes());
    cppcut_assert_equal(grn::dat::UInt32(20), header.max_num_blocks());
    cppcut_assert_equal(grn::dat::UInt32(800), header.key_buf_size());
  }
Пример #12
0
  void test_null(void)
  {
    grn::dat::Trie trie;
    create_trie(&trie);

    grn::dat::PrefixCursor cursor;
    cursor.open(trie, grn::dat::String());
    cppcut_assert_equal(false, cursor.next().is_valid());
  }
Пример #13
0
  void test_null(void)
  {
    grn::dat::Trie trie;
    create_trie(&trie);

    grn::dat::KeyCursor cursor;
    cursor.open(trie, grn::dat::String(), grn::dat::String());
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(4), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(6), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(7), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(2), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(1), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());
  }
Пример #14
0
  void test_initial_values(void)
  {
    const grn::dat::Check check;

    cppcut_assert_equal(false, check.is_offset());
    cppcut_assert_equal(grn::dat::UInt32(0), check.except_is_offset());
    cppcut_assert_equal(false, check.is_phantom());
    cppcut_assert_equal(grn::dat::UInt32(0), check.label());
    cppcut_assert_equal(grn::dat::UInt32(0), check.child());
    cppcut_assert_equal(grn::dat::UInt32(0), check.sibling());
  }
Пример #15
0
  void test_assign_with_length(void)
  {
    char buf[] = "This is a pen.";

    grn::dat::Array<char> array;

    array.assign(buf, sizeof(buf));
    cppcut_assert_equal(buf, array.ptr());
    cppcut_assert_equal(sizeof(buf), static_cast<size_t>(array.size()));

    for (std::size_t i = 0; i < sizeof(buf); ++i) {
      cppcut_assert_equal(buf[i], array[i]);
      cppcut_assert_equal(buf[i], static_cast<const grn::dat::Array<char> &>(array)[i]);
    }
    cppcut_assert_equal(buf, array.begin());
    cppcut_assert_equal(buf,
                        static_cast<const grn::dat::Array<char> &>(array).begin());
    cppcut_assert_equal((buf + sizeof(buf)), array.end());
    cppcut_assert_equal((buf + sizeof(buf)),
                        static_cast<const grn::dat::Array<char> &>(array).end());
  }
Пример #16
0
  void test_base(void)
  {
    grn::dat::Node node;
    grn::dat::Base base;

    cppcut_assert_equal(base, node.base());

    node.set_key_pos(100);
    base.set_key_pos(100);
    cppcut_assert_equal(base, node.base());
    cppcut_assert_equal(base.is_linker(), node.is_linker());
    cppcut_assert_equal(base.key_pos(), node.key_pos());

    node.set_offset(1000);
    base.set_offset(1000);
    cppcut_assert_equal(base, node.base());
    cppcut_assert_equal(base.is_linker(), node.is_linker());
    cppcut_assert_equal(base.offset(), node.offset());
  }
Пример #17
0
  void test_max_by_str(void)
  {
    grn::dat::Trie trie;
    create_trie(&trie);

    grn::dat::KeyCursor cursor;

    cursor.open(trie, grn::dat::String(), grn::dat::String("Elf"));
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(4), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String(), grn::dat::String("F"));
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(4), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String(), grn::dat::String("A"));
    cppcut_assert_equal(false, cursor.next().is_valid());
  }
Пример #18
0
  void test_nonphantom(void)
  {
    grn::dat::Check check;

    check.set_is_offset(true);
    cppcut_assert_equal(true, check.is_offset());

    check.set_label('a');
    cppcut_assert_equal(grn::dat::UInt32('a'), check.label());

    check.set_child('b');
    cppcut_assert_equal(grn::dat::UInt32('b'), check.child());

    check.set_sibling('c');
    cppcut_assert_equal(grn::dat::UInt32('c'), check.sibling());

    cppcut_assert_equal(true, check.is_offset());
    cppcut_assert_equal('a' | grn::dat::UInt32('b' << 9) | grn::dat::UInt32('c' << 18),
                        check.except_is_offset());
    cppcut_assert_equal(false, check.is_phantom());
  }
Пример #19
0
  void test_offset(void)
  {
    grn::dat::Trie trie;
    create_trie(&trie);

    grn::dat::KeyCursor cursor;

    cursor.open(trie, grn::dat::String("Hobbit"), grn::dat::String("Trebor"), 0);
    cppcut_assert_equal(grn::dat::UInt32(7), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(2), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String(), grn::dat::String(), 5);
    cppcut_assert_equal(grn::dat::UInt32(2), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(1), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("Gnome"), grn::dat::String("Trebor"), 2);
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(2), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("Gnome"), grn::dat::String("Trebor"), 100);
    cppcut_assert_equal(false, cursor.next().is_valid());
  }
Пример #20
0
  void test_mutable_values(void)
  {
    grn::dat::Header header;

    header.set_file_size(1000000);
    header.set_max_num_keys(100);
    header.set_max_num_blocks(50);
    header.set_key_buf_size(100000);

    header.set_total_key_length(500);
    header.set_next_key_id(15);
    header.set_max_key_id(14);
    header.set_num_keys(20);
    header.set_num_phantoms(200);
    header.set_num_zombies(300);
    header.set_num_blocks(10);
    header.set_next_key_pos(400);

    cppcut_assert_equal(grn::dat::UInt32(500), header.total_key_length());
    cppcut_assert_equal(grn::dat::MIN_KEY_ID, header.min_key_id());
    cppcut_assert_equal(grn::dat::UInt32(15), header.next_key_id());
    cppcut_assert_equal(grn::dat::UInt32(14), header.max_key_id());
    cppcut_assert_equal(grn::dat::UInt32(20), header.num_keys());
    cppcut_assert_equal(grn::dat::BLOCK_SIZE * 10, header.num_nodes());
    cppcut_assert_equal(grn::dat::UInt32(200), header.num_phantoms());
    cppcut_assert_equal(grn::dat::UInt32(300), header.num_zombies());
    cppcut_assert_equal(grn::dat::UInt32(10), header.num_blocks());
    cppcut_assert_equal(grn::dat::UInt32(400), header.next_key_pos());

    for (grn::dat::UInt32 i = 0; i <= grn::dat::MAX_BLOCK_LEVEL; ++i) {
      header.set_ith_leader(i, i + 1);
    }

    for (grn::dat::UInt32 i = 0; i <= grn::dat::MAX_BLOCK_LEVEL; ++i) {
      cppcut_assert_equal(i + 1, header.ith_leader(i));
    }
  }
Пример #21
0
  void test_descending_cursor(void)
  {
    grn::dat::Trie trie;
    create_trie(&trie);

    grn::dat::PrefixCursor cursor;

    cursor.open(trie, grn::dat::String("東京都庁"), 0,
                0, grn::dat::MAX_UINT32, grn::dat::DESCENDING_CURSOR);
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(1), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("東京都庁"), std::strlen("東京都"),
                0, grn::dat::MAX_UINT32, grn::dat::DESCENDING_CURSOR);
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("東京都庁"), std::strlen("東京都"),
                1, grn::dat::MAX_UINT32, grn::dat::DESCENDING_CURSOR);
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("東京都庁"), std::strlen("東京都"),
                0, 1, grn::dat::DESCENDING_CURSOR);
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("東京都庁"), 0,
                1, grn::dat::MAX_UINT32, grn::dat::DESCENDING_CURSOR);
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(1), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("東京都庁"), 0,
                0, 2, grn::dat::DESCENDING_CURSOR);
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());
  }
Пример #22
0
  void test_initial_values(void)
  {
    const grn::dat::Header header;

    cppcut_assert_equal(grn::dat::UInt64(0), header.file_size());
    cppcut_assert_equal(grn::dat::UInt32(0), header.total_key_length());
    cppcut_assert_equal(grn::dat::MIN_KEY_ID, header.min_key_id());
    cppcut_assert_equal(grn::dat::MIN_KEY_ID, header.next_key_id());
    cppcut_assert_equal(grn::dat::UInt32(0), header.max_key_id());
    cppcut_assert_equal(grn::dat::UInt32(0), header.num_keys());
    cppcut_assert_equal(grn::dat::UInt32(0), header.max_num_keys());
    cppcut_assert_equal(grn::dat::UInt32(0), header.num_nodes());
    cppcut_assert_equal(grn::dat::UInt32(0), header.num_phantoms());
    cppcut_assert_equal(grn::dat::UInt32(0), header.num_zombies());
    cppcut_assert_equal(grn::dat::UInt32(0), header.max_num_nodes());
    cppcut_assert_equal(grn::dat::UInt32(0), header.num_blocks());
    cppcut_assert_equal(grn::dat::UInt32(0), header.max_num_blocks());
    cppcut_assert_equal(grn::dat::UInt32(0), header.next_key_pos());
    cppcut_assert_equal(grn::dat::UInt32(0), header.key_buf_size());
    for (grn::dat::UInt32 i = 0; i <= grn::dat::MAX_BLOCK_LEVEL; ++i) {
      cppcut_assert_equal(grn::dat::INVALID_LEADER, header.ith_leader(i));
    }
  }
Пример #23
0
  void test_str(void)
  {
    grn::dat::Trie trie;
    create_trie(&trie);

    grn::dat::PrefixCursor cursor;

    cursor.open(trie, grn::dat::String("京都"));
    cppcut_assert_equal(grn::dat::UInt32(2), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("京都府"));
    cppcut_assert_equal(grn::dat::UInt32(2), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(4), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("東京"));
    cppcut_assert_equal(grn::dat::UInt32(1), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("東京都"));
    cppcut_assert_equal(grn::dat::UInt32(1), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("東京都庁"));
    cppcut_assert_equal(grn::dat::UInt32(1), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("東京都議会"));
    cppcut_assert_equal(grn::dat::UInt32(1), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());
  }
Пример #24
0
  void test_except_boundary(void)
  {
    grn::dat::Trie trie;
    create_trie(&trie);

    grn::dat::PrefixCursor cursor;

    cursor.open(trie, grn::dat::String("東京都庁ビル"), 0,
                0, grn::dat::UINT32_MAX, grn::dat::EXCEPT_EXACT_MATCH);
    cppcut_assert_equal(grn::dat::UInt32(1), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("東京都庁ビル"), std::strlen("東京"),
                0, grn::dat::UINT32_MAX, grn::dat::EXCEPT_EXACT_MATCH);
    cppcut_assert_equal(grn::dat::UInt32(1), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("東京都庁"), std::strlen("東京"),
                0, grn::dat::UINT32_MAX, grn::dat::EXCEPT_EXACT_MATCH);
    cppcut_assert_equal(grn::dat::UInt32(1), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("京都府"), 0,
                0, grn::dat::UINT32_MAX, grn::dat::EXCEPT_EXACT_MATCH);
    cppcut_assert_equal(grn::dat::UInt32(2), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());
  }
Пример #25
0
  void test_limit(void)
  {
    grn::dat::Trie trie;
    create_trie(&trie);

    grn::dat::KeyCursor cursor;

    cursor.open(trie, grn::dat::String("Gnome"), grn::dat::String("Werdna"),
                0, grn::dat::UINT32_MAX);
    cppcut_assert_equal(grn::dat::UInt32(6), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(7), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(2), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(1), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("Gnome"), grn::dat::String("Werdna"),
                0, 3);
    cppcut_assert_equal(grn::dat::UInt32(6), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(7), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("A"), grn::dat::String("Z"), 3, 2);
    cppcut_assert_equal(grn::dat::UInt32(7), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("A"), grn::dat::String("Z"), 0, 0);
    cppcut_assert_equal(false, cursor.next().is_valid());
  }
Пример #26
0
  void test_descending_cursor(void)
  {
    grn::dat::Trie trie;
    create_trie(&trie);

    grn::dat::KeyCursor cursor;

    cursor.open(trie, grn::dat::String(), grn::dat::String(),
                0, grn::dat::UINT32_MAX, grn::dat::DESCENDING_CURSOR);
    cppcut_assert_equal(grn::dat::UInt32(1), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(2), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(7), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(6), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(4), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("Elf"), grn::dat::String("Human"),
                0, grn::dat::UINT32_MAX, grn::dat::DESCENDING_CURSOR);
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(7), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(6), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(4), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("Dwarf"), grn::dat::String("Trebor"),
                3, 2, grn::dat::DESCENDING_CURSOR);
    cppcut_assert_equal(grn::dat::UInt32(6), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(4), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());
  }
Пример #27
0
  void test_min_length(void)
  {
    grn::dat::Trie trie;
    create_trie(&trie);

    grn::dat::PrefixCursor cursor;

    cursor.open(trie, grn::dat::String("東京都庁ビル"), std::strlen(""));
    cppcut_assert_equal(grn::dat::UInt32(1), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("東京都庁ビル"), std::strlen("東"));
    cppcut_assert_equal(grn::dat::UInt32(1), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("東京都庁ビル"), std::strlen("東京"));
    cppcut_assert_equal(grn::dat::UInt32(1), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("東京都庁ビル"), std::strlen("東京都"));
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("東京都庁ビル"),
                std::strlen("東京都庁"));
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("東京都庁ビル"),
                std::strlen("東京都庁ビル"));
    cppcut_assert_equal(false, cursor.next().is_valid());
  }
Пример #28
0
  void test_except_boundary(void)
  {
    grn::dat::Trie trie;
    create_trie(&trie);

    grn::dat::KeyCursor cursor;

    cursor.open(trie, grn::dat::String(), grn::dat::String(),
                0, grn::dat::UINT32_MAX,
                grn::dat::EXCEPT_LOWER_BOUND | grn::dat::EXCEPT_UPPER_BOUND);
    cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(4), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(6), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(7), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(2), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(1), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("Dwarf"), grn::dat::String("Werdna"),
                0, grn::dat::UINT32_MAX,
                grn::dat::EXCEPT_LOWER_BOUND | grn::dat::EXCEPT_UPPER_BOUND);
    cppcut_assert_equal(grn::dat::UInt32(4), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(6), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(7), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(2), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("Elf"), grn::dat::String("Trebor"),
                2, 100, grn::dat::EXCEPT_LOWER_BOUND);
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(2), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("Elf"), grn::dat::String("Trebor"),
                2, 100, grn::dat::EXCEPT_UPPER_BOUND);
    cppcut_assert_equal(grn::dat::UInt32(7), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());

    cursor.open(trie, grn::dat::String("Fighter"), grn::dat::String("Samurai"),
                0, grn::dat::UINT32_MAX,
                grn::dat::EXCEPT_LOWER_BOUND | grn::dat::EXCEPT_UPPER_BOUND);
    cppcut_assert_equal(grn::dat::UInt32(6), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(7), cursor.next().id());
    cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
    cppcut_assert_equal(false, cursor.next().is_valid());
  }
Пример #29
0
  void test_check(void)
  {
    grn::dat::Node node;
    grn::dat::Check check;

    cppcut_assert_equal(check, node.check());

    node.set_is_offset(true);
    check.set_is_offset(true);
    cppcut_assert_equal(check, node.check());
    cppcut_assert_equal(check.is_offset(), node.is_offset());

    node.set_offset(grn::dat::INVALID_OFFSET);

    node.set_is_phantom(true);
    check.set_is_phantom(true);
    cppcut_assert_equal(check, node.check());
    cppcut_assert_equal(check.is_phantom(), node.is_phantom());

    node.set_next(101);
    node.set_prev(99);
    check.set_next(101);
    check.set_prev(99);
    cppcut_assert_equal(check, node.check());
    cppcut_assert_equal(check.next(), node.next());
    cppcut_assert_equal(check.prev(), node.prev());

    node.set_is_phantom(false);
    check.set_is_phantom(false);
    cppcut_assert_equal(check, node.check());
    cppcut_assert_equal(check.is_phantom(), node.is_phantom());
    cppcut_assert_equal(check.label(), node.label());
    cppcut_assert_equal(check.child(), node.child());
    cppcut_assert_equal(check.sibling(), node.sibling());

    node.set_label('a');
    check.set_label('a');
    cppcut_assert_equal(check, node.check());
    cppcut_assert_equal(check.label(), node.label());
  }
Пример #30
0
 CUT_EXPORT void
 test_compute(void)
 {
     cppcut_assert_equal(2, 3 - 1);
 }