<commit_before>#include <jni.h>
#include <errno.h>

#include <android/sensor.h>
#include <android/log.h>
#include <android_native_app_glue.h>

#include <cstring>
#include <memory>
#include <thread>
#include <unistd.h>

#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunused-private-field"
#endif
# define CATCH_CONFIG_RUNNER
# include <catch.hpp>
#if defined(__clang__)
# pragma clang diagnostic pop
#endif

extern const char* __progname;

static void run_tests()
{
    const int logLevel = ANDROID_LOG_INFO;

    // Create a default config object
    Catch::Config config;

    // Configure CATCH to send all its output to a stringstream
    std::ostringstream oss;
    config.setStreamBuf(oss.rdbuf());

    std::unique_ptr<char[]> progname(new char[strlen(__progname)+1]);
    strcpy(progname.get(), __progname);
    const size_t argc = 1;
    char* const argv[] = { progname.get() };

    __android_log_print(logLevel, progname.get(), "Running unit tests ...");

    // Forward on to CATCH's main, but using our custom config.
    // CATCH will still parse the command line and set the config
    // object up further
    int result = Catch::Main(argc, argv, config);

    __android_log_print(logLevel, progname.get(), "%s", oss.str().c_str());
    __android_log_print(logLevel, progname.get(), "Unit tests returned %d", result);
}

extern "C" void android_main(struct android_app* state)
{
    // Make sure glue isn't stripped.<commit_msg>Fix Android test runner<commit_after>#include <jni.h>
#include <errno.h>

#include <android/sensor.h>
#include <android/log.h>
#include <android_native_app_glue.h>

#include <cstring>
#include <sstream>
#include <string>
#include <thread>
#include <unistd.h>

#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunused-private-field"
#endif
# define CATCH_CONFIG_RUNNER
# include <catch.hpp>
#if defined(__clang__)
# pragma clang diagnostic pop
#endif

extern const char* __progname;

static void run_tests()
{
    const std::string progname(__progname);
    const int logLevel = ANDROID_LOG_INFO;

    __android_log_print(logLevel, progname.c_str(), "Running unit tests ...");

    // Configure CATCH to send all its output to a stringstream
    std::stringstream oss;
    Catch::Ptr<Catch::Config> config = new Catch::Config();
    config->setStreamBuf(oss.rdbuf());
    Catch::Runner runner(config);
    const int result = runner.runTests().assertions.failed;

    __android_log_print(logLevel, progname.c_str(), "%s", oss.str().c_str());
    __android_log_print(logLevel, progname.c_str(), "Unit tests returned %d", result);
}

extern "C" void android_main(struct android_app* state)
{
    // Make sure glue isn't stripped.
{'fraction_non_alphanumeric': 0.12786051580094443, 'fraction_numerical': 0.000726480203414457, 'mean_word_length': 4.574898785425101, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 27, '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': '2203272', 'n_tokens_mistral': 937, 'n_tokens_neox': 901, 'n_words': 250}