| 25 | class MemTableIteratorTest : public ::testing::Test {}; |
| 26 | |
| 27 | TEST_F(MemTableIteratorTest, smoketest) { |
| 28 | std::map<std::string, uint32_t> mapping; |
| 29 | mapping.insert(std::make_pair("idx0", 0)); |
| 30 | MemTable* table = new MemTable("tx_log", 1, 1, 8, mapping, 10, |
| 31 | ::fedb::type::TTLType::kAbsoluteTime); |
| 32 | std::string key = "test"; |
| 33 | std::string value = "test"; |
| 34 | uint64_t now = ::baidu::common::timer::get_micros() / 1000; |
| 35 | table->Init(); |
| 36 | table->Put(key, now, value.c_str(), value.size()); |
| 37 | ::hybridse::vm::WindowIterator* it = table->NewWindowIterator(0); |
| 38 | it->SeekToFirst(); |
| 39 | ASSERT_TRUE(it != NULL); |
| 40 | ASSERT_TRUE(it->Valid()); |
| 41 | ::hybridse::codec::Row row = it->GetKey(); |
| 42 | ASSERT_EQ(row.ToString(), key); |
| 43 | std::unique_ptr<::hybridse::vm::RowIterator> wit = it->GetValue(); |
| 44 | wit->SeekToFirst(); |
| 45 | ASSERT_TRUE(wit->Valid()); |
| 46 | ::hybridse::codec::Row value2 = wit->GetValue(); |
| 47 | ASSERT_EQ(value2.ToString(), value); |
| 48 | ASSERT_EQ(now, wit->GetKey()); |
| 49 | it->Next(); |
| 50 | ASSERT_FALSE(it->Valid()); |
| 51 | } |
| 52 | |
| 53 | } // namespace storage |
| 54 | } // namespace fedb |