Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrognor committed Nov 30, 2024
1 parent d96ff41 commit 7e59c62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 3 additions & 5 deletions Source/Vault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,6 @@ namespace mvlt
if (ds.GetDataType() == paramsIt.second.GetDataType())
{
paramsIt.second.SetDataToRecord(paramsIt.first, newData);

// If key in record template and key tipy match type in param
res.IsOperationSuccess = true;
res.SavedType = paramsIt.second.GetDataType();
res.ResultCode = VaultOperationResultCode::Success;
}
else
{ // If the type in param not match type in record template
Expand Down Expand Up @@ -233,6 +228,9 @@ namespace mvlt
vaultRecordAddersIt.second(newData);

vaultRecordRef.SetRecord(newData, this);

res.IsOperationSuccess = true;
res.ResultCode = VaultOperationResultCode::Success;
}
}
else delete newData;
Expand Down
5 changes: 3 additions & 2 deletions Tests/VaultUnitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void Vault_CreateRecord_Test()
TEST_ASSERT(vlt.CreateRecord({ {"A", 1}, {"D", 1} }).ResultCode == VaultOperationResultCode::WrongKey, "Failed to create record");
TEST_ASSERT(vlt.CreateRecord({ {"A", 1}, {"A", 'a'} }).ResultCode == VaultOperationResultCode::WrongType, "Failed to create record");

// Third method overload
// Second method overload
VaultRecordRef vrr1, vrr2;
vlt.CreateRecord(vrr1, {{"A", 100}});
vlt.GetRecord("A", 100, vrr2);
Expand All @@ -227,7 +227,8 @@ void Vault_CreateRecord_Test()
vlt.AddKey("B", -1);
vlt.AddUniqueKey<int>("C", {[](std::size_t counter, const VaultRecordRef& vrf) -> int { return static_cast<int>(counter); }});

vlt.CreateRecord(vrr1, {{"A", 1}, {"B", 1}, {"C", 1}});
TEST_ASSERT(vlt.CreateRecord(vrr1, {{"A", 1}, {"B", 1}, {"C", 1}}).ResultCode == VaultOperationResultCode::Success, "Unique key adding failed!");

vlt.CreateRecord(vrr1, {{"A", 2}, {"B", 1}, {"C", 2}});
vlt.CreateRecord(vrr1, {{"A", 3}, {"B", 1}, {"C", 3}});

Expand Down

0 comments on commit 7e59c62

Please sign in to comment.