2
* Copyright 2019 by its authors. See AUTHORS.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
22
#include "eina_cxx_suite.h"
24
Eina_Error my_error, my_error_2;
26
EFL_START_TEST(eina_cxx_get_error)
28
efl::eina::eina_init eina_init;
30
my_error = ::eina_error_msg_static_register("Message 1");
34
efl::eina::error_code ec1 = efl::eina::get_error_code();
37
::eina_error_set(my_error);
39
efl::eina::error_code ec2 = efl::eina::get_error_code();
42
ck_assert(ec2.message() == "Message 1");
44
::eina_error_set(ENOMEM);
46
efl::eina::error_code ec3 = efl::eina::get_error_code();
49
ck_assert(ec3.message() == strerror(ENOMEM));
53
EFL_START_TEST(eina_cxx_throw_on_error)
55
efl::eina::eina_init eina_init;
57
::eina_error_set(my_error_2);
58
my_error_2 = ::eina_error_msg_static_register("Message 2");
63
efl::eina::throw_on_error();
65
catch(std::exception const&)
70
::eina_error_set(my_error_2);
73
efl::eina::throw_on_error();
76
catch(efl::eina::system_error const& e)
78
ck_assert(e.code().value() == my_error_2);
79
ck_assert(e.code().message() == "Message 2");
80
ck_assert(!efl::eina::get_error_code());
86
eina_test_error(TCase *tc)
88
tcase_add_test(tc, eina_cxx_get_error);
89
tcase_add_test(tc, eina_cxx_throw_on_error);