<commit_before>/*  libscratch - Multipurpose objective C++ library.
    Copyright (C) 2012 - 2013  <NAME>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>. */

#include <cstdio> // for printf
#include <iostream> // for std::cin.get

#include <Scratch.h>

static INDEX _ctFailed = 0;

#define TEST(expr) ASSERT(expr);    \
  printf("  Test: (%s) ", #expr);   \
  if(!(expr)) {                     \
    _ctFailed++;                    \
    printf("FAILED!\n");            \
  } else {                          \
    printf("OK\n");                 \
  }

void TestString()
{
  printf("Testing strings\n");

  CString strTest;
  strTest += "Lib";
  strTest += "Scratch";
  strTest = strTest.ToLower();
  TEST(strTest == "libscratch");

  strTest += " is great";
  CStackArray<CString> astrParse = strTest.Split(" ");
  TEST(astrParse[2] == "great");
  TEST(astrParse[2][1] == 'r');

  CString strTest2 = strTest.Replace("great", "cool");
  TEST(strTest2 == "libscratch is cool");
}

int main()
{
  TestString();

  if(_ctFailed == 0) {
    printf("\n\nAll OK!\n");
  } else {
    printf("\n\nSome problems seem to have popped up. Please report a bug.\n");
  }

  std::cin.get();
  return 0;
}<commit_msg>Added stack array test<commit_after>/*  libscratch - Multipurpose objective C++ library.
    Copyright (C) 2012 - 2013  <NAME>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>. */

#include <cstdio> // for printf
#include <iostream> // for std::cin.get

#include <Scratch.h>

static INDEX _ctFailed = 0;

#define TEST(expr) {                \
  BOOL bSuccess = (expr);           \
  ASSERT(bSuccess);                 \
  printf("  Test: (%s) ", #expr);   \
  if(!bSuccess) {                   \
    _ctFailed++;                    \
    printf("FAILED!\n");            \
  } else {                          \
    printf("OK\n");                 \
  }                                 \
}

/// String testing
void TestString()
{
  printf("Testing strings\n");

  CString strTest;
  strTest += "Lib";
  strTest += "Scratch";
  strTest = strTest.ToLower();
  TEST(strTest == "libscratch");

  strTest += " is great";
  CStackArray<CString> astrParse = strTest.Split(" ");
  TEST(astrParse[2] == "great");
  TEST(astrParse[2][1] == 'r');

  CString strTest2 = strTest.Replace("great", "cool");
  TEST(strTest2 == "libscratch is cool");
}

/// Stack array testing
void TestStackArray()
{
  printf("Testing stack arrays\n");

  CStackArray<INDEX> aiNumbers;
  TEST(aiNumbers.Count() == 0);

  aiNumbers.Push() = 5;
  aiNumbers.Push() = 10;
  aiNumbers.Push() = 15;
  TEST(aiNumbers.Count() == 3);
  TEST(aiNumbers[0] == 5);
  TEST(aiNumbers[1] == 10);
  TEST(aiNumbers[2] + aiNumbers[0] == 20);

  TEST(aiNumbers.Pop() == 15);
  TEST(aiNumbers.Count() == 2);
}

int main()
{
  // perform tests
  TestString();
  TestStackArray();

  // check if all went OK
  if(_ctFailed == 0) {
    // it did! no failures. :)
    printf("\n\nAll OK!\n");
  } else {
    // oops, there's a bug somewhere. please report!
    printf("\n\nSome problems seem to have popped up. Please report a bug.\n");
  }

  std::cin.get();
  return 0;
}
{'fraction_non_alphanumeric': 0.13419713095788988, 'fraction_numerical': 0.012262841277186487, 'mean_word_length': 2.5492610837438425, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7523855', 'n_tokens_mistral': 1402, 'n_tokens_neox': 1321, 'n_words': 438}