free (const_cast <unsigned char *> (dst_string.text));
/* Verify ranges of individual characters. This no longer includes the
- quotes. */
- for (int i = 0; i <= 9; i++)
+ opening quote, but does include the closing quote. */
+ for (int i = 0; i <= 10; i++)
ASSERT_CHAR_AT_RANGE (test, tok->src_loc, type, i, 1,
10 + i, 10 + i);
- ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, type, 10);
+ ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, type, 11);
}
/* As test_lexer_string_locations_simple, but use an EBCDIC execution
free (const_cast <unsigned char *> (dst_string.text));
/* Verify ranges of individual characters. This no longer includes the
- quotes. */
+ opening quote, but does include the closing quote. */
for (int i = 0; i <= 4; i++)
ASSERT_CHAR_AT_RANGE (test, tok->src_loc, type, i, 1, 10 + i, 10 + i);
ASSERT_CHAR_AT_RANGE (test, tok->src_loc, type, 5, 1, 15, 18);
- for (int i = 6; i <= 9; i++)
+ for (int i = 6; i <= 10; i++)
ASSERT_CHAR_AT_RANGE (test, tok->src_loc, type, i, 1, 13 + i, 13 + i);
- ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, type, 10);
+ ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, type, 11);
}
/* Lex a string literal containing an octal-escaped character.
free (const_cast <unsigned char *> (dst_string.text));
/* Verify ranges of individual characters. This no longer includes the
- quotes. */
+ opening quote, but does include the closing quote. */
for (int i = 0; i < 5; i++)
ASSERT_CHAR_AT_RANGE (test, tok->src_loc, type, i, 1, 10 + i, 10 + i);
ASSERT_CHAR_AT_RANGE (test, tok->src_loc, type, 5, 1, 15, 18);
- for (int i = 6; i <= 9; i++)
+ for (int i = 6; i <= 10; i++)
ASSERT_CHAR_AT_RANGE (test, tok->src_loc, type, i, 1, 13 + i, 13 + i);
- ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, type, 10);
+ ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, type, 11);
}
/* Test of string literal containing letter escapes. */
ASSERT_CHAR_AT_RANGE (test, tok->src_loc, CPP_STRING,
5, 1, 17, 18);
- /* "bar". */
- for (int i = 6; i <= 8; i++)
+ /* "bar" and closing quote for nul-terminator. */
+ for (int i = 6; i <= 9; i++)
ASSERT_CHAR_AT_RANGE (test, tok->src_loc, CPP_STRING,
i, 1, 13 + i, 13 + i);
- ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, CPP_STRING, 9);
+ ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, CPP_STRING, 10);
}
/* Another test of a string literal containing a letter escape.
ASSERT_CHAR_AT_RANGE (test, tok->src_loc, CPP_STRING,
3, 1, 13, 14);
- ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, CPP_STRING, 4);
+ /* Closing quote for nul-terminator. */
+ ASSERT_CHAR_AT_RANGE (test, tok->src_loc, CPP_STRING,
+ 4, 1, 15, 15);
+
+ ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, CPP_STRING, 5);
}
/* Lex a string literal containing UCN 4 characters.
11 0x37 '7' 27
12 0x38 '8' 28
13 0x39 '9' 29
+ 14 0x00 30 (closing quote)
----------- ---- ----- ------- ---------------. */
cpp_string dst_string;
free (const_cast <unsigned char *> (dst_string.text));
/* Verify ranges of individual characters. This no longer includes the
- quotes.
+ opening quote, but does include the closing quote.
'01234'. */
for (int i = 0; i <= 4; i++)
ASSERT_CHAR_AT_RANGE (test, tok->src_loc, type, i, 1, 10 + i, 10 + i);
/* U+2175. */
for (int i = 8; i <= 10; i++)
ASSERT_CHAR_AT_RANGE (test, tok->src_loc, type, i, 1, 21, 26);
- /* '789'. */
- for (int i = 11; i <= 13; i++)
+ /* '789' and nul terminator */
+ for (int i = 11; i <= 14; i++)
ASSERT_CHAR_AT_RANGE (test, tok->src_loc, type, i, 1, 16 + i, 16 + i);
- ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, type, 14);
+ ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, type, 15);
}
/* Lex a string literal containing UCN 8 characters.
free (const_cast <unsigned char *> (dst_string.text));
/* Verify ranges of individual characters. This no longer includes the
- quotes.
+ opening quote, but does include the closing quote.
'01234'. */
for (int i = 0; i <= 4; i++)
ASSERT_CHAR_AT_RANGE (test, tok->src_loc, type, i, 1, 10 + i, 10 + i);
/* '789' at columns 35-37 */
for (int i = 11; i <= 13; i++)
ASSERT_CHAR_AT_RANGE (test, tok->src_loc, type, i, 1, 24 + i, 24 + i);
+ /* Closing quote/nul-terminator at column 38. */
+ ASSERT_CHAR_AT_RANGE (test, tok->src_loc, type, 14, 1, 38, 38);
- ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, type, 14);
+ ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, type, 15);
}
/* Fetch a big-endian 32-bit value and convert to host endianness. */
free (const_cast <unsigned char *> (dst_string.text));
/* Verify ranges of individual characters. This no longer includes the
- quotes. */
- for (int i = 0; i <= 9; i++)
+ opening quote, but does include the closing quote. */
+ for (int i = 0; i <= 10; i++)
ASSERT_CHAR_AT_RANGE (test, tok->src_loc, type, i, 1, 10 + i, 10 + i);
}
free (const_cast <unsigned char *> (dst_string.text));
/* Verify ranges of individual characters. This no longer includes the
- quotes.
+ opening quote, but does include the closing quote.
Assuming that both source and execution encodings are UTF-8, we have
- a run of 25 octets in each. */
+ a run of 25 octets in each, plus the NUL terminator. */
for (int i = 0; i < 25; i++)
ASSERT_CHAR_AT_RANGE (test, tok->src_loc, type, i, 1, 10 + i, 10 + i);
+ /* NUL-terminator should use the closing quote at column 35. */
+ ASSERT_CHAR_AT_RANGE (test, tok->src_loc, type, 25, 1, 35, 35);
- ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, type, 25);
+ ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, type, 26);
}
/* Test of string literal concatenation. */
location_t initial_loc = input_locs[0];
+ /* "01234" on line 1. */
for (int i = 0; i <= 4; i++)
ASSERT_CHAR_AT_RANGE (test, initial_loc, type, i, 1, 10 + i, 10 + i);
- for (int i = 5; i <= 9; i++)
+ /* "56789" in line 2, plus its closing quote for the nul terminator. */
+ for (int i = 5; i <= 10; i++)
ASSERT_CHAR_AT_RANGE (test, initial_loc, type, i, 2, 5 + i, 5 + i);
- ASSERT_NUM_SUBSTRING_RANGES (test, initial_loc, type, 10);
+ ASSERT_NUM_SUBSTRING_RANGES (test, initial_loc, type, 11);
}
/* Another test of string literal concatenation. */
ASSERT_CHAR_AT_RANGE (test, initial_loc, type, (i * 2) + j,
i + 1, 10 + j, 10 + j);
- ASSERT_NUM_SUBSTRING_RANGES (test, initial_loc, type, 10);
+ /* NUL-terminator should use the final closing quote at line 5 column 12. */
+ ASSERT_CHAR_AT_RANGE (test, initial_loc, type, 10, 5, 12, 12);
+
+ ASSERT_NUM_SUBSTRING_RANGES (test, initial_loc, type, 11);
}
/* Another test of string literal concatenation, this time combined with
for (int i = 7; i <= 9; i++)
ASSERT_CHAR_AT_RANGE (test, initial_loc, type, i, 1, 28 + i, 28 + i);
- ASSERT_NUM_SUBSTRING_RANGES (test, initial_loc, type, 10);
+ /* NUL-terminator should use the location of the final closing quote. */
+ ASSERT_CHAR_AT_RANGE (test, initial_loc, type, 10, 1, 38, 38);
+
+ ASSERT_NUM_SUBSTRING_RANGES (test, initial_loc, type, 11);
}
/* Test of string literal in a macro. */
/* Verify ranges of individual characters. We ought to
see columns within the macro definition. */
- for (int i = 0; i <= 9; i++)
+ for (int i = 0; i <= 10; i++)
ASSERT_CHAR_AT_RANGE (test, tok->src_loc, CPP_STRING,
i, 1, 20 + i, 20 + i);
- ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, CPP_STRING, 10);
+ ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, CPP_STRING, 11);
tok = test.get_token ();
ASSERT_EQ (tok->type, CPP_PADDING);
return;
/* Verify ranges of individual characters. */
- ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, CPP_STRING, 130);
- for (int i = 0; i < 130; i++)
+ ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, CPP_STRING, 131);
+ for (int i = 0; i < 131; i++)
ASSERT_CHAR_AT_RANGE (test, tok->src_loc, CPP_STRING,
i, 2, 7 + i, 7 + i);
}