1 /* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15
16 #include "tensorflow/lite/micro/examples/micro_speech/feature_provider.h"
17
18 #include "tensorflow/lite/c/common.h"
19 #include "tensorflow/lite/micro/examples/micro_speech/micro_features/micro_model_settings.h"
20 #include "tensorflow/lite/micro/micro_error_reporter.h"
21 #include "tensorflow/lite/micro/testing/micro_test.h"
22
23 TF_LITE_MICRO_TESTS_BEGIN
24
TF_LITE_MICRO_TEST(TestFeatureProvider)25 TF_LITE_MICRO_TEST(TestFeatureProvider) {
26 tflite::MicroErrorReporter micro_error_reporter;
27
28 int8_t feature_data[kFeatureElementCount];
29 FeatureProvider feature_provider(kFeatureElementCount, feature_data);
30
31 int how_many_new_slices = 0;
32 TfLiteStatus populate_status = feature_provider.PopulateFeatureData(
33 µ_error_reporter, /* last_time_in_ms= */ 0, /* time_in_ms= */ 10000,
34 &how_many_new_slices);
35 TF_LITE_MICRO_EXPECT_EQ(kTfLiteOk, populate_status);
36 TF_LITE_MICRO_EXPECT_EQ(kFeatureSliceCount, how_many_new_slices);
37 }
38
39 TF_LITE_MICRO_TESTS_END
40