mirror of
https://github.com/vee1e/tflite-micro.git
synced 2026-09-01 09:51:22 +00:00
* Fixed StackAllocator * Bumped kStackAllocatorSize to 16KB * Simplified * Added micro_test v2 * Sample migration * More APIs * Fixed format * Output is more aligned with gtest * Removed legacy-eq * Migrated memory_planner tests * Code style * Added ~~~ALL TESTS PASSED~~~ * Review * Review 2 * Output messages
57 lines
1.6 KiB
C++
57 lines
1.6 KiB
C++
// Copyright 2024 The TensorFlow Authors. All Rights Reserved.
|
|
//
|
|
// 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 "tensorflow/lite/micro/span.h"
|
|
|
|
#include <array>
|
|
|
|
#include "tensorflow/lite/micro/testing/micro_test_v2.h"
|
|
|
|
TEST(SpanTest, TestArrayInitialization) {
|
|
int a[]{1, 2, 3};
|
|
tflite::Span<int> s{a};
|
|
EXPECT_EQ(s.data(), a);
|
|
EXPECT_EQ(s.size(), sizeof(a) / sizeof(int));
|
|
}
|
|
|
|
TEST(SpanTest, TestStdArrayInitialization) {
|
|
std::array<char, 20> a;
|
|
tflite::Span<char> s{a};
|
|
EXPECT_EQ(s.data(), a.data());
|
|
EXPECT_EQ(s.size(), a.size());
|
|
}
|
|
|
|
TEST(SpanTest, TestEquality) {
|
|
constexpr int a[]{1, 2, 3};
|
|
constexpr int b[]{1, 2, 3};
|
|
constexpr int c[]{3, 2, 1};
|
|
tflite::Span<const int> s_a{a};
|
|
tflite::Span<const int> s_b{b};
|
|
tflite::Span<const int> s_c{c};
|
|
EXPECT_TRUE(s_a == s_b);
|
|
EXPECT_FALSE(s_a == s_c);
|
|
}
|
|
|
|
TEST(SpanTest, TestInequality) {
|
|
constexpr int a[]{1, 2, 3};
|
|
constexpr int b[]{1, 2, 3};
|
|
constexpr int c[]{3, 2, 1};
|
|
tflite::Span<const int> s_a{a};
|
|
tflite::Span<const int> s_b{b};
|
|
tflite::Span<const int> s_c{c};
|
|
EXPECT_FALSE(s_a != s_b);
|
|
EXPECT_TRUE(s_a != s_c);
|
|
}
|
|
|
|
TF_LITE_MICRO_TESTS_MAIN
|