<commit_before>/*
**
** Copyright (C) 2012 Aldebaran Robotics
*/

#include <gtest/gtest.h>
#include <qi/application.hpp>
#include <qi/log.hpp>
#include <qi/session.hpp>

TEST(ServiceDirectory, DoubleListen)
{
  qi::Session sd;

  try {
    sd.listenStandalone("tcp://127.0.0.1:0");
    sd.listen("tcp://127.0.0.1:0");
  }
  catch(std::runtime_error& e)
  {
    qiLogError("test_sd") << e.what();
    ASSERT_TRUE(false);
  }
}

struct Serv
{
  static int response = 4242;
  int f()
  {
    return response;
  }
};
QI_REGISTER_OBJECT(Serv, f);

TEST(ServiceDirectory, MultiRegister)
{
  qi::Session sd1;
  qi::Session sd2;

  sd1.listenStandalone("tcp://127.0.0.1:0");
  sd2.listenStandalone("tcp://127.0.0.1:0");

  sd1.registerService("Serv", boost::make_shared<Serv>());
  sd2.registerService("Serv", boost::make_shared<Serv>());

  {
    qi::Session client;<commit_msg>Service Directory: fix compilation after test change<commit_after>/*
**
** Copyright (C) 2012 Aldebaran Robotics
*/

#include <gtest/gtest.h>
#include <qi/application.hpp>
#include <qi/log.hpp>
#include <qi/session.hpp>

TEST(ServiceDirectory, DoubleListen)
{
  qi::Session sd;

  try {
    sd.listenStandalone("tcp://127.0.0.1:0");
    sd.listen("tcp://127.0.0.1:0");
  }
  catch(std::runtime_error& e)
  {
    qiLogError("test_sd") << e.what();
    ASSERT_TRUE(false);
  }
}

struct Serv
{
  static const int response;
  int f()
  {
    return response;
  }
};
const int Serv::response = 4242;

QI_REGISTER_OBJECT(Serv, f);

TEST(ServiceDirectory, MultiRegister)
{
  qi::Session sd1;
  qi::Session sd2;

  sd1.listenStandalone("tcp://127.0.0.1:0");
  sd2.listenStandalone("tcp://127.0.0.1:0");

  sd1.registerService("Serv", boost::make_shared<Serv>());
  sd2.registerService("Serv", boost::make_shared<Serv>());

  {
    qi::Session client;
{'fraction_non_alphanumeric': 0.18853362734288864, 'fraction_numerical': 0.04630650496141125, 'mean_word_length': 4.127118644067797, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 8, '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': '2856582', 'n_tokens_mistral': 752, 'n_tokens_neox': 699, 'n_words': 113}