Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,63 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzNetworking/DataStructures/FixedSizeBitset.h>
#include <AzCore/UnitTest/TestTypes.h>
namespace UnitTest
{
TEST(FixedSizeBitset, TestSetBit)
{
AzNetworking::FixedSizeBitset<128> test;
test.SetBit(0, true);
test.SetBit(2, true);
// 0000 0101
EXPECT_EQ(test.GetContainer()[0], 0x05);
}
TEST(FixedSizeBitset, TestAppend)
{
AzNetworking::FixedSizeBitset<63> appendTest1;
appendTest1.SetBit(1, true);
AzNetworking::FixedSizeBitset<63> appendTest2;
appendTest2.SetBit(2, true);
appendTest2.SetBit(32, true);
appendTest1 |= appendTest2;
EXPECT_EQ(appendTest1.GetBit(1), true);
EXPECT_EQ(appendTest1.GetBit(2), true);
EXPECT_EQ(appendTest1.GetBit(32), true);
}
TEST(FixedSizeBitset, TestAllSet)
{
AzNetworking::FixedSizeBitset<63> unusedBitTest(true);
bool allSet = true;
for (uint32_t i = 0; i < 63; ++i)
{
allSet &= unusedBitTest.GetBit(i);
}
EXPECT_EQ(allSet, true);
}
TEST(FixedSizeBitset, TestAnySet)
{
AzNetworking::FixedSizeBitset<9> unusedBitTest(true);
for (uint32_t i = 0; i < 9; ++i)
{
unusedBitTest.SetBit(i, false);
}
EXPECT_FALSE(unusedBitTest.AnySet());
}
}
@@ -0,0 +1,49 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzNetworking/DataStructures/FixedSizeBitsetView.h>
#include <AzNetworking/DataStructures/FixedSizeBitset.h>
#include <AzCore/UnitTest/TestTypes.h>
namespace UnitTest
{
TEST(FixedSizeBitsetView, BasicTests)
{
AzNetworking::FixedSizeBitset<100> bitset;
{
AzNetworking::FixedSizeBitsetView view(bitset, 10, 1);
EXPECT_FALSE(bitset.GetBit(10));
EXPECT_FALSE(view.GetBit(0));
view.SetBit(0, true);
EXPECT_TRUE(bitset.GetBit(10));
EXPECT_TRUE(view.GetBit(0));
bitset.SetBit(10, false);
EXPECT_FALSE(view.GetBit(0));
}
{
AzNetworking::FixedSizeBitsetView view(bitset, 20, 1);
EXPECT_FALSE(view.GetBit(0));
EXPECT_FALSE(bitset.GetBit(20));
view.SetBit(0, true);
EXPECT_TRUE(bitset.GetBit(20));
EXPECT_TRUE(view.GetBit(0));
bitset.SetBit(20, false);
EXPECT_FALSE(view.GetBit(0));
}
}
}
@@ -0,0 +1,18 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzNetworking/DataStructures/FixedSizeVectorBitset.h>
#include <AzCore/UnitTest/TestTypes.h>
namespace UnitTest
{
}
@@ -0,0 +1,83 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzNetworking/DataStructures/RingBufferBitset.h>
#include <AzCore/UnitTest/TestTypes.h>
namespace UnitTest
{
AzNetworking::RingbufferBitset<128> test;
TEST(RingbufferBitset, Push2Bits)
{
test.PushBackBits(2);
test.SetBit(0, true);
test.SetBit(1, true);
EXPECT_TRUE(test.GetBit(0));
EXPECT_TRUE(test.GetBit(1));
}
TEST(RingbufferBitset, Push4Bits)
{
test.PushBackBits(2);
EXPECT_FALSE(test.GetBit(0));
EXPECT_FALSE(test.GetBit(1));
EXPECT_TRUE (test.GetBit(2));
EXPECT_TRUE (test.GetBit(3));
}
TEST(RingbufferBitset, Push44Bits)
{
test.PushBackBits(40);
test.SetBit(41, true);
EXPECT_FALSE(test.GetBit(40));
EXPECT_TRUE (test.GetBit(41));
EXPECT_TRUE (test.GetBit(42));
EXPECT_TRUE (test.GetBit(43));
}
TEST(RingbufferBitset, Push84Bits)
{
test.PushBackBits(40);
test.SetBit(80, true);
EXPECT_TRUE(test.GetBit(80));
EXPECT_TRUE(test.GetBit(81));
EXPECT_TRUE(test.GetBit(82));
EXPECT_TRUE(test.GetBit(83));
}
TEST(RingbufferBitset, Push124Bits)
{
test.PushBackBits(40);
EXPECT_TRUE(test.GetBit(120));
EXPECT_TRUE(test.GetBit(121));
EXPECT_TRUE(test.GetBit(122));
EXPECT_TRUE(test.GetBit(123));
}
TEST(RingbufferBitset, TestWrap)
{
// Bits should reset to false after wrapping and falling out of our window
test.PushBackBits(40);
EXPECT_FALSE(test.GetBit(160 - 128));
EXPECT_FALSE(test.GetBit(161 - 128));
EXPECT_FALSE(test.GetBit(162 - 128));
EXPECT_FALSE(test.GetBit(163 - 128));
}
}
@@ -0,0 +1,18 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzNetworking/DataStructures/TimeoutQueue.h>
#include <AzCore/UnitTest/TestTypes.h>
namespace UnitTest
{
}