github.com/igggame/nebulas-go@v2.1.0+incompatible/nbre/test/fs/blockchain/gtest_trie.cpp (about)

     1  // Copyright (C) 2018 go-nebulas authors
     2  //
     3  // This file is part of the go-nebulas library.
     4  //
     5  // the go-nebulas library is free software: you can redistribute it and/or
     6  // modify
     7  // it under the terms of the GNU General Public License as published by
     8  // the Free Software Foundation, either version 3 of the License, or
     9  // (at your option) any later version.
    10  //
    11  // the go-nebulas library is distributed in the hope that it will be useful,
    12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  // GNU General Public License for more details.
    15  //
    16  // You should have received a copy of the GNU General Public License
    17  // along with the go-nebulas library.  If not, see
    18  // <http://www.gnu.org/licenses/>.
    19  //
    20  
    21  #include "common/configuration.h"
    22  #include "fs/blockchain.h"
    23  #include "fs/blockchain/trie/trie.h"
    24  #include <gtest/gtest.h>
    25  
    26  TEST(test_fs, key_to_route) {
    27  
    28    neb::bytes key(std::initializer_list<neb::byte_t>({0xa1, 0xf2}));
    29    neb::bytes route_expect(
    30        std::initializer_list<neb::byte_t>({0xa, 0x1, 0xf, 0x2}));
    31  
    32    auto route_actual = neb::fs::trie::key_to_route(key);
    33    ASSERT_EQ(route_expect.size(), route_actual.size());
    34    for (size_t i = 0; i < route_actual.size(); i++) {
    35      ASSERT_EQ(route_expect[i], route_actual[i]);
    36    }
    37  }
    38  
    39  TEST(test_fs, route_to_key) {
    40  
    41    neb::bytes route(std::initializer_list<neb::byte_t>({0xa, 0x1, 0xf, 0x2}));
    42    neb::bytes key_expect(std::initializer_list<neb::byte_t>({0xa1, 0xf2}));
    43  
    44    auto key_actual = neb::fs::trie::route_to_key(route);
    45    ASSERT_EQ(key_expect.size(), key_actual.size());
    46    for (size_t i = 0; i < key_actual.size(); i++) {
    47      ASSERT_EQ(key_expect[i], key_actual[i]);
    48    }
    49  }
    50  
    51  TEST(test_fs, get_trie_node) {}