Skip to content

Commit

Permalink
Boolean type and constants
Browse files Browse the repository at this point in the history
This patch updates the core/types.h header to ensure that the C99
boolean type and true/false constants are available.
  • Loading branch information
Douglas Creager committed Jun 20, 2011
1 parent c42a4ea commit d1d6339
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
12 changes: 10 additions & 2 deletions include/libcork/core/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* @addtogroup basic_types Basic types
*
* <tt>#%include &lt;libcork/core/types.h&gt;</tt>
* <tt>#%include \<libcork/core/types.h\></tt>
*
* The types in this section ensure that the C99 integer types are
* available, regardless of platform. We also define some preprocessor
Expand All @@ -37,6 +37,13 @@
* just to trick doxygen into generating an entry for them.
*/

/** @brief A boolean. @since 0.0-dev */
typedef int bool;
/** @brief The boolean “true” value. @since 0.0-dev */
#define true 1
/** @brief The boolean “false” value. @since 0.0-dev */
#define false 0

/** @brief A signed 8-bit integer. @since 0.0-dev */
typedef char int8_t;
/** @brief An unsigned 8-bit integer. @since 0.0-dev */
Expand Down Expand Up @@ -83,11 +90,12 @@ typedef unsigned long uintptr_t;

/*
* For now, we assume that the C99 integer types are available using the
* standard header.
* standard headers.
*/

#include <limits.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Expand Down
13 changes: 13 additions & 0 deletions tests/test-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@
* Core types
*/

START_TEST(test_bool)
{
bool value;

value = true;
fail_unless(value, "Unexpected true value");

value = false;
fail_if(value, "Unexpected false value");
}
END_TEST

START_TEST(test_int_types)
{
/*
Expand Down Expand Up @@ -158,6 +170,7 @@ test_suite()
Suite *s = suite_create("core");

TCase *tc_core = tcase_create("core");
tcase_add_test(tc_core, test_bool);
tcase_add_test(tc_core, test_int_types);
tcase_add_test(tc_core, test_int_sizeof);
tcase_add_test(tc_core, test_endianness);
Expand Down

0 comments on commit d1d6339

Please sign in to comment.