This repository has been archived by the owner on Nov 17, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matthias Clasen
committed
May 16, 2006
1 parent
503db3a
commit 49ab402
Showing
9 changed files
with
214 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#undef G_DISABLE_ASSERT | ||
#undef G_LOG_DOMAIN | ||
|
||
#include <errno.h> | ||
#include <string.h> | ||
#include <glib.h> | ||
|
||
|
||
static void | ||
test_uint64 (const gchar *str, | ||
const gchar *end, | ||
gint base, | ||
guint64 result, | ||
gint error) | ||
{ | ||
guint64 actual; | ||
gchar *endptr = NULL; | ||
gint err; | ||
|
||
errno = 0; | ||
actual = g_ascii_strtoull (str, &endptr, base); | ||
err = errno; | ||
|
||
g_assert (actual == result); | ||
g_assert (strcmp (end, endptr) == 0); | ||
g_assert (err == error); | ||
} | ||
|
||
static void | ||
test_int64 (const gchar *str, | ||
const gchar *end, | ||
gint base, | ||
gint64 result, | ||
gint error) | ||
{ | ||
gint64 actual; | ||
gchar *endptr = NULL; | ||
gint err; | ||
|
||
errno = 0; | ||
actual = g_ascii_strtoll (str, &endptr, base); | ||
err = errno; | ||
|
||
g_assert (actual == result); | ||
g_assert (strcmp (end, endptr) == 0); | ||
g_assert (err == error); | ||
} | ||
|
||
int | ||
main (int argc, char *argv[]) | ||
{ | ||
test_uint64 ("0", "", 10, 0, 0); | ||
test_uint64 ("+0", "", 10, 0, 0); | ||
test_uint64 ("-0", "", 10, 0, 0); | ||
test_uint64 ("18446744073709551615", "", 10, G_MAXUINT64, 0); | ||
test_uint64 ("18446744073709551616", "", 10, G_MAXUINT64, ERANGE); | ||
test_uint64 ("20xyz", "xyz", 10, 20, 0); | ||
test_uint64 ("-1", "", 10, G_MAXUINT64, 0); | ||
|
||
test_int64 ("0", "", 10, 0, 0); | ||
test_int64 ("9223372036854775807", "", 10, G_MAXINT64, 0); | ||
test_int64 ("9223372036854775808", "", 10, G_MAXINT64, ERANGE); | ||
test_int64 ("-9223372036854775808", "", 10, G_MININT64, 0); | ||
test_int64 ("-9223372036854775809", "", 10, G_MININT64, ERANGE); | ||
|
||
return 0; | ||
} |