<commit_before>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

/*
 * Copyright (c) 2016 <NAME>
 */

#include "ctache_data.h"
#include "render.h"
#include "utest.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

UTEST_BEGIN(test_string_as_boolean)
{
    ctache_data_t *data = ctache_data_create_hash();
    ctache_data_t *value = ctache_data_create_string("test", 4);
    ctache_data_hash_table_set(data, "key", value);

    char template_str[] = "value = {{#key}}{{key}}{{/key}}";
    FILE *fp = tmpfile();
    u_assert(fp != NULL, "output file is NULL");

    ctache_render_string(template_str,
                         strlen(template_str),
                         fp,
                         data,
                         ESCAPE_HTML,
                         "{{",
                         "}}");
    fseek(fp, 0, SEEK_SET);
    chat output[100];
    memset(output, 0, 100);
    fgets(output, 100, fp);

    char correct_output[] = "value = test";
    u_assert_str_eq(correct_output, output, "Wrong output for string-as-bool");

    fclose(fp);
    ctache_data_destroy(data);
}
UTEST_END

int
main(void)
{
    int num_failures;
    struct utest_suite *suite;<commit_msg>Fix a typo in test_boolean.c<commit_after>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

/*
 * Copyright (c) 2016 <NAME>
 */

#include "ctache_data.h"
#include "render.h"
#include "utest.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

UTEST_BEGIN(test_string_as_boolean)
{
    ctache_data_t *data = ctache_data_create_hash();
    ctache_data_t *value = ctache_data_create_string("test", 4);
    ctache_data_hash_table_set(data, "key", value);

    char template_str[] = "value = {{#key}}{{key}}{{/key}}";
    FILE *fp = tmpfile();
    u_assert(fp != NULL, "output file is NULL");

    ctache_render_string(template_str,
                         strlen(template_str),
                         fp,
                         data,
                         ESCAPE_HTML,
                         "{{",
                         "}}");
    fseek(fp, 0, SEEK_SET);
    char output[100];
    memset(output, 0, 100);
    fgets(output, 100, fp);

    char correct_output[] = "value = test";
    u_assert_str_eq(correct_output, output, "Wrong output for string-as-bool");

    fclose(fp);
    ctache_data_destroy(data);
}
UTEST_END

int
main(void)
{
    int num_failures;
    struct utest_suite *suite;
{'fraction_non_alphanumeric': 0.1327694005148952, 'fraction_numerical': 0.01471129091577786, 'mean_word_length': 2.4961439588688945, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1163060', 'n_tokens_mistral': 990, 'n_tokens_neox': 904, 'n_words': 225}