MCPcopy Create free account
hub / github.com/catboost/catboost / TestRead

Method TestRead

library/cpp/archive/directory_models_archive_reader_ut.cpp:28–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26const TString TEST_TEXT = "Test Text.";
27
28void TDirectoryModelsArchiveReaderTest::TestRead() {
29 TTempDir mainDir(MAIN_DIR);
30 TTempDir subDir(MAIN_DIR + SUBDIR);
31 TTempFileHandle file1(MAIN_DIR + SAMPLE_FILE1);
32 TTempFileHandle file2(MAIN_DIR + SUBDIR + SAMPLE_FILE2);
33
34 file1.Write(TEST_TEXT.data(), TEST_TEXT.size());
35 file1.FlushData();
36
37 TDirectoryModelsArchiveReader reader(MAIN_DIR, false);
38
39 UNIT_ASSERT_EQUAL(reader.Count(), 2);
40
41 UNIT_ASSERT(reader.Has(SAMPLE_FILE1));
42 UNIT_ASSERT(reader.Has(SUBDIR + SAMPLE_FILE2));
43
44 UNIT_ASSERT_EQUAL(reader.KeyByIndex(0), SAMPLE_FILE1);
45 UNIT_ASSERT_EQUAL(reader.KeyByIndex(1), SUBDIR + SAMPLE_FILE2);
46
47 TBlob blob = reader.BlobByKey(SAMPLE_FILE1);
48 Cout << "'" << TString(blob.AsCharPtr(), blob.Size()) << "' - '" << TEST_TEXT << "'" << Endl;
49 UNIT_ASSERT_VALUES_EQUAL(TString(blob.AsCharPtr(), blob.Size()), TString(TEST_TEXT));
50
51 TAutoPtr<IInputStream> is = reader.ObjectByKey(SAMPLE_FILE1);
52 const TString data = is->ReadAll();
53 Cout << "'" << data << "' - '" << TEST_TEXT << "'" << Endl;
54 UNIT_ASSERT_VALUES_EQUAL(data, TEST_TEXT);
55}

Callers

nothing calls this directly

Calls 12

AsCharPtrMethod · 0.80
ReadAllMethod · 0.80
WriteMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
FlushDataMethod · 0.45
CountMethod · 0.45
HasMethod · 0.45
KeyByIndexMethod · 0.45
BlobByKeyMethod · 0.45
SizeMethod · 0.45
ObjectByKeyMethod · 0.45

Tested by

no test coverage detected