Skip to content

Instantly share code, notes, and snippets.

@smspillaz
Created December 26, 2013 21:03
Show Gist options
  • Save smspillaz/8138673 to your computer and use it in GitHub Desktop.
Save smspillaz/8138673 to your computer and use it in GitHub Desktop.
G_FILE_CREATE_REPLACE_DESTINATION
static void
test_coverage_data_file_is_overwritten_completely(gpointer fixture_data,
gconstpointer user_data)
{
GjsDebugCoverageToSingleOutputFileFixture *fixture = (GjsDebugCoverageToSingleOutputFileFixture *) fixture_data;
/* Write the string "existing contents" about one hundred times to the file
* and check that the new file does not contain any string matching it */
const gchar *existing_contents = "existing_contents\n";
guint i = 0;
for (; i < 100; ++i)
{
if (write(fixture->output_file_handle,
(gconstpointer) existing_contents,
sizeof(gchar) * strlen(existing_contents)) == -1)
g_error("Failed to write to existing contents file");
}
gchar *coverage_data_contents =
eval_script_and_get_coverage_data(fixture->base_fixture.context,
fixture->base_fixture.coverage,
fixture->base_fixture.temporary_js_script_filename,
fixture->output_file_name,
NULL);
g_assert(strstr(coverage_data_contents, existing_contents) == NULL);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment