Skip to content

Commit b952429

Browse files
authored
Merge pull request #71 from sourceryinstitute/test-string-constructor
test(string_t):allow larger numeric representation
2 parents cc823d9 + 68b3d37 commit b952429

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/sourcery/sourcery_string_s.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
end procedure
2626

2727
module procedure from_real
28-
integer, parameter :: sign_ = 1, decimal_ = 1, digits = precision(x) + 3, exponent_width = 4
29-
character(len=sign_ + decimal_ + digits + exponent_width) characters
28+
integer, parameter :: sign_ = 1, decimal_ = 1, digits = precision(x) + 6, exponent = 4
29+
character(len=sign_ + decimal_ + digits + exponent) characters
3030
write(characters, '(g0)') x
3131
string = string_t(characters)
3232
end procedure

test/string_test.f90

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ function assigns_character_to_string_t() result(passed)
142142
logical passed
143143
character(len=*), parameter :: rhs = "well, alrighty then"
144144
type(string_t) lhs
145+
145146
lhs = rhs
146147
passed = lhs == rhs
147148
end function
@@ -157,34 +158,39 @@ function supports_concatenation_operator() result(passed)
157158

158159
function constructs_from_default_integer() result(passed)
159160
logical passed
161+
160162
associate(string => string_t(1234567890))
161163
passed = adjustl(trim(string%string())) == "1234567890"
162164
end associate
163165
end function
164166

165167
function constructs_from_real() result(passed)
166168
logical passed
167-
associate(string => string_t(123456789E+09))
168-
passed = adjustl(trim(string%string())) == "0.123456791E+18"
169+
170+
associate(string => string_t(-1.53018260E-15))
171+
passed = adjustl(trim(string%string())) == "-0.153018260E-14"
169172
end associate
170173
end function
171174

172175
function extracts_file_base_name() result(passed)
173176
logical passed
177+
174178
associate(string => string_t(" foo .bar.too "))
175179
passed = string%base_name() == "foo .bar"
176180
end associate
177181
end function
178182

179183
function extracts_file_name_extension() result(passed)
180184
logical passed
185+
181186
associate(string => string_t(" foo .bar.too "))
182187
passed = string%file_extension() == "too"
183188
end associate
184189
end function
185190

186191
function concatenates_elements() result(passed)
187192
logical passed
193+
188194
associate(elements => [string_t("foo"), string_t("bar")])
189195
passed = .cat. elements == "foobar"
190196
end associate

0 commit comments

Comments
 (0)