OVMS3-idf/components/nvs_flash/test_nvs_host/test_compressed_enum_table.cpp
antti d390449371 add unit tests to esp-idf
rename nvs host test folder, modify .gitlab-ci.yml

remove unit-test-app build

re-format unit test files

remove extra newlines in project.mk

some refactoring for unit test part in project.mk

add build files of unit-test-app in gitignore

add README.md for unit test app

correct headings in README.md

remove files and make minor tweaks in unit test app

update .gitlab-ci.yml to use unit test app

delete unused lines in component_wrapper.mk

delete periph_i2s.h and lcd test

add text floating point in components/esp32/test/Kconfig

correct idf test build paths in .gitlab-ci.yml
2016-11-22 14:45:50 +08:00

56 lines
1.7 KiB
C++

// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "catch.hpp"
#include "compressed_enum_table.hpp"
#include <cstring>
TEST_CASE("test if CompressedEnumTable works as expected", "[enumtable]")
{
enum class TEnum1 : uint32_t {
ZERO = 0,
ONE = 1,
TWO = 2,
THREE = 3,
};
CompressedEnumTable<TEnum1, 2, 252> table;
memset(table.data(), 0xff, table.byteSize());
for (size_t i = 0; i < table.count(); ++i) {
CHECK(table.get(i) == TEnum1::THREE);
}
table.set(0, TEnum1::ONE);
table.set(1, TEnum1::TWO);
table.set(2, TEnum1::ZERO);
table.set(3, TEnum1::ONE);
table.set(4, TEnum1::TWO);
table.set(5, TEnum1::ZERO);
table.set(6, TEnum1::ONE);
table.set(7, TEnum1::TWO);
table.set(8, TEnum1::ZERO);
table.set(9, TEnum1::ZERO);
table.set(10, TEnum1::ONE);
table.set(11, TEnum1::TWO);
// table.set(12, ...
table.set(13, TEnum1::ZERO);
table.set(14, TEnum1::ONE);
table.set(15, TEnum1::TWO);
// b10010011100100001001001001001001
// h 9 3 9 0 9 2 4 9
CHECK(table.data()[0] == 0x93909249);
}