f12ac29eff96966b92e5e543c59fd1ed0e7b2660
[AGL/documentation.git] / docs / 4_APIs_and_Services / 4.4_AGL_Test_Framework / 5_Reference / 4_LuaUnit_Assertion_Functions / 1_Value_Assertions.md
1 ---
2 edit_link: ''
3 title: Value Assertions
4 origin_url: >-
5   https://git.automotivelinux.org/apps/app-afb-test/plain/docs/Reference/LuaUnitAssertionFunctions/1_ValueAssertions.md?h=master
6 ---
7
8 <!-- WARNING: This file is generated by fetch_docs.js using /home/boron/Documents/AGL/docs-webtemplate/site/_data/tocs/apis_services/master/app-afb-test-developer-guides-api-services-book.yml -->
9
10 # Value assertions
11
12 * **_AFT.assertEvalToTrue(value)**
13
14     Assert that a given value evals to true. Lua coercion rules are applied so
15     that values like 0,"",1.17 succeed in this assertion. If provided, extra_msg
16     is a string which will be printed along with the failure message.
17
18 * **_AFT.assertEvalToFalse(Value)**
19
20     Assert that a given value eval to *false*. Lua coercion rules are applied so
21     that *nil* and *false* succeed in this assertion. If provided, extra_msg is a
22     string which will be printed along with the failure message.
23
24 * **_AFT.assertIsTrue(value)**
25
26     Assert that a given value compares to true. Lua coercion rules are applied so
27     that values like 0, "", 1.17 all compare to true.
28
29 * **_AFT.assertIsFalse(value)**
30
31     Assert that a given value compares to false. Lua coercion rules are applied so
32     that only nil and false all compare to false.
33
34 * **_AFT.assertIsNil(value)**
35
36     Assert that a given value is nil .
37
38 * **_AFT.assertNotIsNil(value)**
39
40     Assert that a given value is not *nil* . Lua coercion rules are applied
41     so that values like ``0``, ``""``, ``false`` all validate the assertion.
42     If provided, *extra_msg* is a string which will be printed along with the
43     failure message.
44
45 * **_AFT.assertIs(actual, expected)**
46
47     Assert that two variables are identical. For string, numbers, boolean and
48     for nil, this gives the same result as assertEquals() . For the other types,
49     identity means that the two variables refer to the same object.
50
51     Example :
52
53 ```lua
54     s1='toto'
55     s2='to'..'to'
56     t1={1,2}
57     t2={1,2}
58     luaunit.assertIs(s1,s1) -- ok
59     luaunit.assertIs(s1,s2) -- ok
60     luaunit.assertIs(t1,t1) -- ok
61     luaunit.assertIs(t1,t2) -- fail
62 ```
63
64 * **_AFT.assertNotIs(actual, expected)**
65
66     Assert that two variables are not identical, in the sense that they do not
67     refer to the same value. See assertIs() for more details.