Commit Graph

3 Commits

Author SHA1 Message Date
Peter Wang
bfe14f9128 Fix string.base_string_to_int succeeding incorrectly.
string.base_string_to_int would incorrectly succeed on an input string
containing a code point of multiple code units.  string.foldl_between
expects the length of the string in code units, but was passed the
length of the string in code points.

library/string.m:
	As above.

tests/general/base_string_to_int_test.exp:
tests/general/base_string_to_int_test.m:
	Extend test case.
2013-02-11 11:04:21 +11:00
Ian MacLarty
8d365b4056 Change string.base_string_to_int so that it doesn't fail if the base is 10 and
the integer is int.min_int.  The previous behaviour seems unintuitive and means
we can't use the literal -2147483648 in Mercury programs on 32 bit machines,
even though that number can be represented in 32 bits.

library/string.m:
    If the integer to be parsed is negative, then use a negative accumulator,
    so that if the number is int.min_int it doesn't cause an overflow.

tests/general/base_string_to_int_test.exp:
tests/general/base_string_to_int_test.m:
    Test it.
2010-01-14 06:55:53 +00:00
Ralph Becket
e1c6ed1409 Added a test case for string.base_string_to_int/3.
Estimated hours taken: 0.2
Branches: main

tests/general/Mmakefile:
tests/general/base_string_to_int.m:
tests/general/base_string_to_int.exp:
	Added a test case for string.base_string_to_int/3.
2004-07-01 06:20:14 +00:00