Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core / Tests/unit/core] : Fix build 'test_valuerecorder'. #1590

Merged
merged 12 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/core/ValueRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ namespace Core {
ASSERT((_storage[_index] & 0x80) == 0);

// we need to loopback for another 0..
while ((_storage[_index - 1] & 0x80) != 0) {
while (_index > 0 && (_storage[_index - 1] & 0x80) != 0) {
result = (result << 7) | (_storage[_index] & 0x7F);
_index--;
stepBack++;
Expand Down
2 changes: 1 addition & 1 deletion Tests/unit/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ add_executable(${TEST_RUNNER_NAME}
test_time.cpp
test_timer.cpp
test_tristate.cpp
#test_valuerecorder.cpp
test_valuerecorder.cpp
test_weblinkjson.cpp
test_weblinktext.cpp
test_websocketjson.cpp
Expand Down
36 changes: 24 additions & 12 deletions Tests/unit/core/test_valuerecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ class WriterClass : public RecorderType<uint32_t, BLOCKSIZE>::Writer
{
uint8_t arr[] = {1,2,3};
SetBuffer(arr);
Create(_file);
auto object = Create(_file);
Record(10);
Time();
Source();
Value();
uint64_t TimeValue = Time();
std::string storageName = Source();
uint32_t value = Value();
object.Release();
}

private:
Expand Down Expand Up @@ -82,14 +83,18 @@ class ReaderClass : public RecorderType<uint32_t, BLOCKSIZE>::Reader
public:
void ReaderJob()
{
Next();
EXPECT_TRUE(IsValid());

uint32_t time = 20;
Core::Time curTime = Core::Time::Now();
curTime.Add(time);
Store(curTime.Ticks(), 1);
uint32_t index = Store(curTime.Ticks(), 1);

StepForward();
StepBack();
ClearData();

Reader obj1(_file, 1u);
EXPECT_FALSE(obj1.Previous());
EXPECT_TRUE(obj1.Next());
Expand All @@ -101,8 +106,8 @@ class ReaderClass : public RecorderType<uint32_t, BLOCKSIZE>::Reader
else
EXPECT_EQ(EndId(),2u);

EndId();
Source();
uint32_t id = EndId();
std::string storageName = Source();
}

private:
Expand All @@ -112,12 +117,19 @@ class ReaderClass : public RecorderType<uint32_t, BLOCKSIZE>::Reader
TEST(test_valuerecorder, test_writer)
{
string filename = "baseRecorder.txt";
WriterClass obj1(filename);
obj1.Copy(obj1,1);
obj1.Copy(obj1,100);
obj1.WriterJob();

auto obj1 = RecorderType<uint32_t, BLOCKSIZE>::Writer::Create(filename);

obj1->Copy(*(obj1),1);
obj1->Copy(*(obj1),100);

static_cast<WriterClass&>(*obj1).WriterJob();

ReaderClass obj2(filename);
obj2.ReaderJob();
ReaderClass obj3(ProxyType<WriterClass>(obj1));

ReaderClass obj4(ProxyType<WriterClass>(obj3));

obj1.Release();
}

Loading