<commit_before>/******************************************************************
 *
 * Round for C
 *
 * Copyright (C) <NAME> 2015
 *
 * This is licensed under BSD-style license, see file COPYING.
 *
 ******************************************************************/

#include <boost/test/unit_test.hpp>

#include <round/const.h>
#include <round/node_internal.h>

BOOST_AUTO_TEST_SUITE(node)

BOOST_AUTO_TEST_CASE(NodeNew)
{
  RoundNode *node = round_node_new();
  BOOST_CHECK(node);
  
  BOOST_CHECK(round_node_delete(node));
}

BOOST_AUTO_TEST_CASE(NodeBaseMember)
{
  const char *TEST_NODE_ADDR = "testaddr";
  const int TEST_NODE_PORT = 4649;
  const char *TEST_NODE_CLUSTER = "testcluster";
  const int TEST_NODE_TIMEOUT = 120;
  
  RoundNode *node = round_node_new();
  BOOST_CHECK(node);
  
  const char *addr;
  int port;
  const char *cluster;
  
  BOOST_CHECK(!round_node_getaddress(node, &addr));
  BOOST_CHECK(!round_node_getport(node, &port));
  BOOST_CHECK(round_node_getclustername(node, &cluster));
  BOOST_CHECK_EQUAL(round_node_getrequesttimeout(node), ROUND_JSON_RPC_REQUEST_TIMEOUT_SEC);
  
  BOOST_CHECK(round_node_setaddress(node, TEST_NODE_ADDR));
  BOOST_CHECK(round_node_setport(node, TEST_NODE_PORT));
  BOOST_CHECK(round_node_setclustername(node, TEST_NODE_CLUSTER));
  BOOST_CHECK(round_node_setrequesttimeout(node, TEST_NODE_TIMEOUT));

  BOOST_CHECK(round_node_getaddress(node, &addr));
  BOOST_CHECK(round_node_getport(node, &port));
  BOOST_CHECK(round_node_getclustername(node, &cluster));
  BOOST_CHECK_EQUAL(round_node_getrequesttimeout(node), TEST_NODE_TIMEOUT);
  
  BOOST_CHECK_EQUAL(addr, TEST_NODE_ADDR);
  BOOST_CHECK_EQUAL(port, TEST_NODE_PORT);
  BOOST_CHECK_EQUAL(cluster, TEST_NODE_CLUSTER);
  
  BOOST_CHECK(round_node_delete(node));<commit_msg>* Added test cases for round_node_hasdigest().<commit_after>/******************************************************************
 *
 * Round for C
 *
 * Copyright (C) <NAME> 2015
 *
 * This is licensed under BSD-style license, see file COPYING.
 *
 ******************************************************************/

#include <boost/test/unit_test.hpp>

#include <round/const.h>
#include <round/node_internal.h>

BOOST_AUTO_TEST_SUITE(node)

BOOST_AUTO_TEST_CASE(NodeNew)
{
  RoundNode *node = round_node_new();
  BOOST_CHECK(node);
  
  BOOST_CHECK(!round_node_hasdigest(node));
  
  BOOST_CHECK(round_node_delete(node));
}

BOOST_AUTO_TEST_CASE(NodeBaseMember)
{
  const char *TEST_NODE_ADDR = "testaddr";
  const int TEST_NODE_PORT = 4649;
  const char *TEST_NODE_CLUSTER = "testcluster";
  const int TEST_NODE_TIMEOUT = 120;
  
  RoundNode *node = round_node_new();
  BOOST_CHECK(node);
  
  const char *addr;
  int port;
  const char *cluster;
  
  BOOST_CHECK(!round_node_getaddress(node, &addr));
  BOOST_CHECK(!round_node_getport(node, &port));
  BOOST_CHECK(round_node_getclustername(node, &cluster));
  BOOST_CHECK(!round_node_hasdigest(node));
  BOOST_CHECK_EQUAL(round_node_getrequesttimeout(node), ROUND_JSON_RPC_REQUEST_TIMEOUT_SEC);
  
  BOOST_CHECK(round_node_setaddress(node, TEST_NODE_ADDR));
  BOOST_CHECK(round_node_setport(node, TEST_NODE_PORT));
  BOOST_CHECK(round_node_setclustername(node, TEST_NODE_CLUSTER));
  BOOST_CHECK(round_node_setrequesttimeout(node, TEST_NODE_TIMEOUT));

  BOOST_CHECK(round_node_getaddress(node, &addr));
  BOOST_CHECK(round_node_getport(node, &port));
  BOOST_CHECK(round_node_getclustername(node, &cluster));
  BOOST_CHECK(round_node_hasdigest(node));
  BOOST_CHECK_EQUAL(round_node_getrequesttimeout(node), TEST_NODE_TIMEOUT);
  
  BOOST_CHECK_EQUAL(addr, TEST_NODE_ADDR);
  BOOST_CHECK_EQUAL(port, TEST_NODE_PORT);
  BOOST_CHECK_EQUAL(cluster, TEST_NODE_CLUSTER);
  
  BOOST_CHECK(round_node_delete(node));
{'fraction_non_alphanumeric': 0.1722118711738089, 'fraction_numerical': 0.005855735959542188, 'mean_word_length': 7.639080459770115, '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': '4780140', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1274, 'n_words': 187}