Debian Codegraph @

crt/aws-c-common/tests/logging/logging_misc.c

raw symbols SCIP
1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #include <aws/common/logging.h>
7
8 #include <aws/testing/aws_test_harness.h>
9
10 static int s_string_to_log_level_success_test(struct aws_allocator *allocator, void *ctx) {
11 (void)ctx;
12 (void)allocator;
13
14 enum aws_log_level level = AWS_LL_NONE;
15
16 ASSERT_SUCCESS(aws_string_to_log_level("DeBug", &level));
17 ASSERT_INT_EQUALS(level, AWS_LL_DEBUG);
18
19 ASSERT_SUCCESS(aws_string_to_log_level("TRACE", &level));
20 ASSERT_INT_EQUALS(level, AWS_LL_TRACE);
21
22 ASSERT_SUCCESS(aws_string_to_log_level("warn", &level));
23 ASSERT_INT_EQUALS(level, AWS_LL_WARN);
24
25 ASSERT_SUCCESS(aws_string_to_log_level("InFo", &level));
26 ASSERT_INT_EQUALS(level, AWS_LL_INFO);
27
28 ASSERT_SUCCESS(aws_string_to_log_level("errOr", &level));
29 ASSERT_INT_EQUALS(level, AWS_LL_ERROR);
30
31 ASSERT_SUCCESS(aws_string_to_log_level("FATAL", &level));
32 ASSERT_INT_EQUALS(level, AWS_LL_FATAL);
33
34 ASSERT_SUCCESS(aws_string_to_log_level("none", &level));
35 ASSERT_INT_EQUALS(level, AWS_LL_NONE);
36
37 return 0;
38 }
39 AWS_TEST_CASE(string_to_log_level_success_test, s_string_to_log_level_success_test)
40
41 static int s_string_to_log_level_failure_test(struct aws_allocator *allocator, void *ctx) {
42 (void)ctx;
43 (void)allocator;
44
45 enum aws_log_level level = AWS_LL_NONE;
46
47 ASSERT_FAILS(aws_string_to_log_level("", &level));
48 ASSERT_FAILS(aws_string_to_log_level("Tracee", &level));
49 ASSERT_FAILS(aws_string_to_log_level("war", &level));
50 ASSERT_FAILS(aws_string_to_log_level("Not a log level", &level));
51 ASSERT_FAILS(aws_string_to_log_level(NULL, &level));
52 ASSERT_FAILS(aws_string_to_log_level(NULL, NULL));
53 ASSERT_FAILS(aws_string_to_log_level("FATAL", NULL));
54
55 return 0;
56 }
57 AWS_TEST_CASE(string_to_log_level_failure_test, s_string_to_log_level_failure_test)