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

Method MatchOrUpdateGolden

library/cpp/testing/gtest/matchers.cpp:9–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#include <util/system/fs.h>
8
9bool NGTest::NDetail::MatchOrUpdateGolden(std::string_view actualContent, const TString& goldenFilename) {
10 if (!GetTestParam("GTEST_UPDATE_GOLDEN").empty()) {
11 Y_ENSURE(NFs::MakeDirectoryRecursive(TFsPath(goldenFilename).Parent()));
12 TFile file(goldenFilename, CreateAlways);
13 file.Write(actualContent.data(), actualContent.size());
14 Cerr << "The data[" << actualContent.size() << "] has written to golden file " << goldenFilename << Endl;
15 return true;
16 }
17
18 if (!NFs::Exists(goldenFilename)) {
19 return actualContent.empty();
20 }
21 TFile goldenFile(goldenFilename, RdOnly);
22 return actualContent == TFileInput(goldenFile).ReadAll();
23}

Callers

nothing calls this directly

Calls 9

MakeDirectoryRecursiveFunction · 0.85
ParentMethod · 0.80
ReadAllMethod · 0.80
TFsPathClass · 0.50
TFileInputClass · 0.50
emptyMethod · 0.45
WriteMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected