Files
microsoft-krabsetw/tests/krabstests/test_synth_record.cpp
T
Zac Brown c81c3c41f6 - Make projects for Managed and Native example code. (#3)
* - Make projects for Managed and Native example code.
- Create a 'tests' directory.
- Remove SampleCSharpKrabsExe as it is redundant with respect to the example code.

Signed-off-by: Zac Brown (ODSP SECURITY) <zbrown@microsoft.com>

* - Add note about TYPEASSERT and NDEBUG compilation flags to README.md.
- Add /W4 /WX compiler flags to NativeExample project.
- vcxproj.filters updates based on VS magic.

Signed-off-by: Zac Brown (ODSP SECURITY) <zbrown@microsoft.com>
2016-11-28 14:06:40 -08:00

44 lines
1.2 KiB
C++

// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include "CppUnitTest.h"
#include <krabs.hpp>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace krabstests
{
TEST_CLASS(test_synth_record)
{
public:
TEST_METHOD(should_deep_copy)
{
EVENT_RECORD record;
std::vector<BYTE> data{ 0 };
krabs::testing::synth_record first(record, data);
krabs::testing::synth_record second(first);
auto& first_rec = reinterpret_cast<EVENT_RECORD&>(first);
auto& second_rec = reinterpret_cast<EVENT_RECORD&>(second);
Assert::AreNotEqual(second_rec.UserData, first_rec.UserData);
}
TEST_METHOD(should_move)
{
EVENT_RECORD record;
std::vector<BYTE> data{ 0 };
krabs::testing::synth_record first(record, data);
auto first_data = reinterpret_cast<EVENT_RECORD&>(first).UserData;
krabs::testing::synth_record second(std::move(first));
auto& second_rec = (EVENT_RECORD&)second;
Assert::AreEqual(second_rec.UserData, first_data);
}
};
}