<commit_before>///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
///		By making use of the Software for military purposes, you choose to make
///		a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtc/gtc_matrix_inverse.cpp
/// @date 2010-09-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////

#include <glm/gtc/matrix_inverse.hpp>

int main()
{
	int Error = 0;

	return Error;
}
<commit_msg>Added tests for affineInverse #192<commit_after>///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
///		By making use of the Software for military purposes, you choose to make
///		a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtc/gtc_matrix_inverse.cpp
/// @date 2010-09-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////

#include <glm/gtc/matrix_inverse.hpp>
#include <glm/gtc/epsilon.hpp>

int test_affine()
{
	int Error = 0;

	{
		glm::mat3 const M(
			2.f, 0.f, 0.f,
			0.f, 2.f, 0.f,
			0.f, 0.f, 1.f);

		glm::mat3 const A = glm::affineInverse(M);
		glm::mat3 const I = glm::inverse(M);

		glm::mat3 const R = glm::affineInverse(A);

		Error += M != A;
		Error += M == R;
		Error += A == I;
	}

	{
		glm::mat4 const M(
			2.f, 0.f, 0.f, 0.f,
			0.f, 2.f, 0.f, 0.f,
			0.f, 0.f, 2.f, 0.f,
			0.f, 0.f, 0.f, 1.f);

		glm::mat4 const A = glm::affineInverse(M);
		glm::mat4 const I = glm::inverse(M);

		glm::mat4 const R = glm::affineInverse(A);

		Error += M != A;
		Error += M == R;
		Error += A == I;
	}

	return Error;
}

int main()
{
	int Error = 0;

	Error += test_affine();

	return Error;
}
<|endoftext|>


<commit_before>/*
  Copyright © 2014 Jesse 'Jeaye' Wilkerson
  See licensing at:
    http://opensource.org/licenses/MIT

  Author: Jesse 'Jeaye' Wilkerson
*/

#pragma once

#include <jest/jest.hpp>

#include <jtl/iterator/range.hpp>

#include <algorithm>

namespace jtl
{
  struct indirect_range_test{};
  using indirect_range_group = jest::group<indirect_range_test>;
  static indirect_range_group const indirect_range_obj{ "indirect_range" };

  struct direct_range_test{};
  using direct_range_group = jest::group<direct_range_test>;
  static direct_range_group const direct_range_obj{ "direct_range" };
}

namespace jest
{
  template <> template <>
  void jtl::indirect_range_group::test<0>() /* Construction */
  {
    jtl::iterator::range::indirect<void*, void*> const r
    { nullptr, nullptr };

    expect_equal(r.begin(), nullptr);
    expect_equal(r.cbegin(), nullptr);
    expect_equal(r.end(), nullptr);
    expect_equal(r.cend(), nullptr);
  }

  template <> template <>
  void jtl::indirect_range_group::test<1>() /* Move construction */
  {
    int *begin{}, *end{};
    jtl::iterator::range::indirect<int*, int*> const r
    { std::move(begin), std::move(end) };

    expect_equal(r.begin(), nullptr);
    expect_equal(r.cbegin(), nullptr);
    expect_equal(r.end(), nullptr);
    expect_equal(r.cend(), nullptr);
  }

  template <> template <>
  void jtl::indirect_range_group::test<2>() /* Algorithms */
  {
    auto const arr{ 0, 1, 2 };

    int should_be{};
    for(auto const &i : jtl::it::make_range(std::begin(arr), std::end(arr)))
    { expect_equal(i, should_be++); }
  }

  template <> template <>
  void jtl::direct_range_group::test<0>() /* Container */
  {
    jtl::it::range::detail::direct_container<int, int, int> dc
    { 0, 42 };
    expect_equal(*dc.begin(), 0);
    expect_equal(*dc.end(), 42);

    expect_equal(*(++dc.begin()), 1);
  }

  template <> template <>
  void jtl::direct_range_group::test<1>() /* Range-based for */
  {
    int should_be{};
    for(auto const &i : jtl::it::make_range(0, 3))
    { expect_equal(i, should_be++); }
    expect_equal(should_be, 3);

    for(auto const &i : jtl::it::make_range(should_be, should_be + 5))
    { expect_equal(i, should_be++); }
    expect_equal(should_be, 8);
  }

  template <> template <>
  void jtl::direct_range_group::test<2>() /* Arrays */
  {
    float constexpr arr[]{ 1.11f, 2.22f, 3.33f };
    int index{};
    for(auto const f : jtl::it::make_range(arr))
    { expect_equal(f, arr[index++]); }
  }

  template <> template <>
  void jtl::direct_range_group::test<3>() /* Containers */
  {
    std::vector<float> const vec{ 1.11f, 2.22f, 3.33f };
    int index{};
    for(auto const f : jtl::it::make_range(vec))
    { expect_equal(f, vec[index++]); }
    expect_equal(index, 3);
  }

  template <> template <>
  void jtl::direct_range_group::test<4>() /* From size */
  {
    std::vector<float> const vec{ 1.11f, 2.22f, 3.33f };
    std::size_t index{};
    for(auto const i : jtl::it::make_range(vec.size()))
    { expect_equal(i, index++); }
    expect_equal(index, 3ul);
  }
}
<commit_msg>Use initializer_list to avoid error on GCC 5.1.0<commit_after>/*
  Copyright © 2014 Jesse 'Jeaye' Wilkerson
  See licensing at:
    http://opensource.org/licenses/MIT

  Author: Jesse 'Jeaye' Wilkerson
*/

#pragma once

#include <jest/jest.hpp>

#include <jtl/iterator/range.hpp>

#include <algorithm>

namespace jtl
{
  struct indirect_range_test{};
  using indirect_range_group = jest::group<indirect_range_test>;
  static indirect_range_group const indirect_range_obj{ "indirect_range" };

  struct direct_range_test{};
  using direct_range_group = jest::group<direct_range_test>;
  static direct_range_group const direct_range_obj{ "direct_range" };
}

namespace jest
{
  template <> template <>
  void jtl::indirect_range_group::test<0>() /* Construction */
  {
    jtl::iterator::range::indirect<void*, void*> const r
    { nullptr, nullptr };

    expect_equal(r.begin(), nullptr);
    expect_equal(r.cbegin(), nullptr);
    expect_equal(r.end(), nullptr);
    expect_equal(r.cend(), nullptr);
  }

  template <> template <>
  void jtl::indirect_range_group::test<1>() /* Move construction */
  {
    int *begin{}, *end{};
    jtl::iterator::range::indirect<int*, int*> const r
    { std::move(begin), std::move(end) };

    expect_equal(r.begin(), nullptr);
    expect_equal(r.cbegin(), nullptr);
    expect_equal(r.end(), nullptr);
    expect_equal(r.cend(), nullptr);
  }

  template <> template <>
  void jtl::indirect_range_group::test<2>() /* Algorithms */
  {
    std::initializer_list<int> const arr{ 0, 1, 2 };

    int should_be{};
    for(auto const &i : jtl::it::make_range(std::begin(arr), std::end(arr)))
    { expect_equal(i, should_be++); }
  }

  template <> template <>
  void jtl::direct_range_group::test<0>() /* Container */
  {
    jtl::it::range::detail::direct_container<int, int, int> dc
    { 0, 42 };
    expect_equal(*dc.begin(), 0);
    expect_equal(*dc.end(), 42);

    expect_equal(*(++dc.begin()), 1);
  }

  template <> template <>
  void jtl::direct_range_group::test<1>() /* Range-based for */
  {
    int should_be{};
    for(auto const &i : jtl::it::make_range(0, 3))
    { expect_equal(i, should_be++); }
    expect_equal(should_be, 3);

    for(auto const &i : jtl::it::make_range(should_be, should_be + 5))
    { expect_equal(i, should_be++); }
    expect_equal(should_be, 8);
  }

  template <> template <>
  void jtl::direct_range_group::test<2>() /* Arrays */
  {
    float constexpr arr[]{ 1.11f, 2.22f, 3.33f };
    int index{};
    for(auto const f : jtl::it::make_range(arr))
    { expect_equal(f, arr[index++]); }
  }

  template <> template <>
  void jtl::direct_range_group::test<3>() /* Containers */
  {
    std::vector<float> const vec{ 1.11f, 2.22f, 3.33f };
    int index{};
    for(auto const f : jtl::it::make_range(vec))
    { expect_equal(f, vec[index++]); }
    expect_equal(index, 3);
  }

  template <> template <>
  void jtl::direct_range_group::test<4>() /* From size */
  {
    std::vector<float> const vec{ 1.11f, 2.22f, 3.33f };
    std::size_t index{};
    for(auto const i : jtl::it::make_range(vec.size()))
    { expect_equal(i, index++); }
    expect_equal(index, 3ul);
  }
}
<|endoftext|>


<commit_before>#include "test/mocks/stream_info/mocks.h"

#include "common/network/address_impl.h"

#include "gmock/gmock.h"
#include "gtest/gtest.h"

using testing::_;
using testing::Const;
using testing::Invoke;
using testing::ReturnPointee;
using testing::ReturnRef;

namespace Envoy {
namespace StreamInfo {

MockStreamInfo::MockStreamInfo()
    : start_time_(ts_.systemTime()),
      filter_state_(std::make_shared<FilterStateImpl>(FilterState::LifeSpan::FilterChain)),
      downstream_local_address_(new Network::Address::Ipv4Instance("127.0.0.2")),
      downstream_direct_remote_address_(new Network::Address::Ipv4Instance("127.0.0.1")),
      downstream_remote_address_(new Network::Address::Ipv4Instance("127.0.0.1")) {
  ON_CALL(*this, setResponseFlag(_)).WillByDefault(Invoke([this](ResponseFlag response_flag) {
    response_flags_ |= response_flag;
  }));
  ON_CALL(*this, startTime()).WillByDefault(ReturnPointee(&start_time_));
  ON_CALL(*this, startTimeMonotonic()).WillByDefault(ReturnPointee(&start_time_monotonic_));
  ON_CALL(*this, lastDownstreamRxByteReceived())
      .WillByDefault(ReturnPointee(&last_downstream_rx_byte_received_));
  ON_CALL(*this, firstUpstreamTxByteSent())
      .WillByDefault(ReturnPointee(&first_upstream_tx_byte_sent_));
  ON_CALL(*this, lastUpstreamTxByteSent())
      .WillByDefault(ReturnPointee(&last_upstream_tx_byte_sent_));
  ON_CALL(*this, firstUpstreamRxByteReceived())
      .WillByDefault(ReturnPointee(&first_upstream_rx_byte_received_));
  ON_CALL(*this, lastUpstreamRxByteReceived())
      .WillByDefault(ReturnPointee(&last_upstream_rx_byte_received_));
  ON_CALL(*this, firstDownstreamTxByteSent())
      .WillByDefault(ReturnPointee(&first_downstream_tx_byte_sent_));
  ON_CALL(*this, lastDownstreamTxByteSent())
      .WillByDefault(ReturnPointee(&last_downstream_tx_byte_sent_));
  ON_CALL(*this, requestComplete()).WillByDefault(ReturnPointee(&end_time_));
  ON_CALL(*this, onRequestComplete()).WillByDefault(Invoke([this]() {
    end_time_ = absl::make_optional<std::chrono::nanoseconds>(
        std::chrono::duration_cast<std::chrono::nanoseconds>(ts_.systemTime() - start_time_)
            .count());
  }));
  ON_CALL(*this, setUpstreamLocalAddress(_))
      .WillByDefault(
          Invoke([this](const Network::Address::InstanceConstSharedPtr& upstream_local_address) {
            upstream_local_address_ = upstream_local_address;
          }));
  ON_CALL(*this, upstreamLocalAddress()).WillByDefault(ReturnRef(upstream_local_address_));
  ON_CALL(*this, setDownstreamLocalAddress(_))
      .WillByDefault(
          Invoke([this](const Network::Address::InstanceConstSharedPtr& downstream_local_address) {
            downstream_local_address_ = downstream_local_address;
          }));
  ON_CALL(*this, downstreamLocalAddress()).WillByDefault(ReturnRef(downstream_local_address_));
  ON_CALL(*this, setDownstreamDirectRemoteAddress(_))
      .WillByDefault(Invoke(
          [this](const Network::Address::InstanceConstSharedPtr& downstream_direct_remote_address) {
            downstream_direct_remote_address_ = downstream_direct_remote_address;
          }));
  ON_CALL(*this, downstreamDirectRemoteAddress())
      .WillByDefault(ReturnRef(downstream_direct_remote_address_));
  ON_CALL(*this, setDownstreamRemoteAddress(_))
      .WillByDefault(
          Invoke([this](const Network::Address::InstanceConstSharedPtr& downstream_remote_address) {
            downstream_remote_address_ = downstream_remote_address;
          }));
  ON_CALL(*this, downstreamRemoteAddress()).WillByDefault(ReturnRef(downstream_remote_address_));
  ON_CALL(*this, setDownstreamSslConnection(_))
      .WillByDefault(Invoke(
          [this](const auto& connection_info) { downstream_connection_info_ = connection_info; }));
  ON_CALL(*this, setUpstreamSslConnection(_))
      .WillByDefault(Invoke(
          [this](const auto& connection_info) { upstream_connection_info_ = connection_info; }));
  ON_CALL(*this, downstreamSslConnection()).WillByDefault(Invoke([this]() {
    return downstream_connection_info_;
  }));
  ON_CALL(*this, upstreamSslConnection()).WillByDefault(Invoke([this]() {
    return upstream_connection_info_;
  }));
  ON_CALL(*this, protocol()).WillByDefault(ReturnPointee(&protocol_));
  ON_CALL(*this, responseCode()).WillByDefault(ReturnPointee(&response_code_));
  ON_CALL(*this, responseCodeDetails()).WillByDefault(ReturnPointee(&response_code_details_));
  ON_CALL(*this, addBytesReceived(_)).WillByDefault(Invoke([this](uint64_t bytes_received) {
    bytes_received_ += bytes_received;
  }));
  ON_CALL(*this, bytesReceived()).WillByDefault(ReturnPointee(&bytes_received_));
  ON_CALL(*this, addBytesSent(_)).WillByDefault(Invoke([this](uint64_t bytes_sent) {
    bytes_sent_ += bytes_sent;
  }));
  ON_CALL(*this, bytesSent()).WillByDefault(ReturnPointee(&bytes_sent_));
  ON_CALL(*this, hasResponseFlag(_)).WillByDefault(Invoke([this](ResponseFlag flag) {
    return response_flags_ & flag;
  }));
  ON_CALL(*this, upstreamHost()).WillByDefault(ReturnPointee(&host_));

  ON_CALL(*this, dynamicMetadata()).WillByDefault(ReturnRef(metadata_));
  ON_CALL(Const(*this), dynamicMetadata()).WillByDefault(ReturnRef(metadata_));
  ON_CALL(*this, filterState()).WillByDefault(ReturnRef(filter_state_));
  ON_CALL(Const(*this), filterState()).WillByDefault(ReturnRef(*filter_state_));
  ON_CALL(*this, upstreamFilterState()).WillByDefault(ReturnRef(upstream_filter_state_));
  ON_CALL(*this, setUpstreamFilterState(_))
      .WillByDefault(Invoke([this](const FilterStateSharedPtr& filter_state) {
        upstream_filter_state_ = filter_state;
      }));
  ON_CALL(*this, setRequestedServerName(_))
      .WillByDefault(Invoke([this](const absl::string_view requested_server_name) {
        requested_server_name_ = std::string(requested_server_name);
      }));
  ON_CALL(*this, requestedServerName()).WillByDefault(ReturnRef(requested_server_name_));
  ON_CALL(*this, setRouteName(_)).WillByDefault(Invoke([this](const absl::string_view route_name) {
    route_name_ = std::string(route_name);
  }));
  ON_CALL(*this, getRouteName()).WillByDefault(ReturnRef(route_name_));
  ON_CALL(*this, upstreamTransportFailureReason())
      .WillByDefault(ReturnRef(upstream_transport_failure_reason_));
}

MockStreamInfo::~MockStreamInfo() = default;

} // namespace StreamInfo
} // namespace Envoy
<commit_msg>stream_info: add response_flags mocks (#10215)<commit_after>#include "test/mocks/stream_info/mocks.h"

#include "common/network/address_impl.h"

#include "gmock/gmock.h"
#include "gtest/gtest.h"

using testing::_;
using testing::Const;
using testing::Invoke;
using testing::Return;
using testing::ReturnPointee;
using testing::ReturnRef;

namespace Envoy {
namespace StreamInfo {

MockStreamInfo::MockStreamInfo()
    : start_time_(ts_.systemTime()),
      filter_state_(std::make_shared<FilterStateImpl>(FilterState::LifeSpan::FilterChain)),
      downstream_local_address_(new Network::Address::Ipv4Instance("127.0.0.2")),
      downstream_direct_remote_address_(new Network::Address::Ipv4Instance("127.0.0.1")),
      downstream_remote_address_(new Network::Address::Ipv4Instance("127.0.0.1")) {
  ON_CALL(*this, setResponseFlag(_)).WillByDefault(Invoke([this](ResponseFlag response_flag) {
    response_flags_ |= response_flag;
  }));
  ON_CALL(*this, startTime()).WillByDefault(ReturnPointee(&start_time_));
  ON_CALL(*this, startTimeMonotonic()).WillByDefault(ReturnPointee(&start_time_monotonic_));
  ON_CALL(*this, lastDownstreamRxByteReceived())
      .WillByDefault(ReturnPointee(&last_downstream_rx_byte_received_));
  ON_CALL(*this, firstUpstreamTxByteSent())
      .WillByDefault(ReturnPointee(&first_upstream_tx_byte_sent_));
  ON_CALL(*this, lastUpstreamTxByteSent())
      .WillByDefault(ReturnPointee(&last_upstream_tx_byte_sent_));
  ON_CALL(*this, firstUpstreamRxByteReceived())
      .WillByDefault(ReturnPointee(&first_upstream_rx_byte_received_));
  ON_CALL(*this, lastUpstreamRxByteReceived())
      .WillByDefault(ReturnPointee(&last_upstream_rx_byte_received_));
  ON_CALL(*this, firstDownstreamTxByteSent())
      .WillByDefault(ReturnPointee(&first_downstream_tx_byte_sent_));
  ON_CALL(*this, lastDownstreamTxByteSent())
      .WillByDefault(ReturnPointee(&last_downstream_tx_byte_sent_));
  ON_CALL(*this, requestComplete()).WillByDefault(ReturnPointee(&end_time_));
  ON_CALL(*this, onRequestComplete()).WillByDefault(Invoke([this]() {
    end_time_ = absl::make_optional<std::chrono::nanoseconds>(
        std::chrono::duration_cast<std::chrono::nanoseconds>(ts_.systemTime() - start_time_)
            .count());
  }));
  ON_CALL(*this, setUpstreamLocalAddress(_))
      .WillByDefault(
          Invoke([this](const Network::Address::InstanceConstSharedPtr& upstream_local_address) {
            upstream_local_address_ = upstream_local_address;
          }));
  ON_CALL(*this, upstreamLocalAddress()).WillByDefault(ReturnRef(upstream_local_address_));
  ON_CALL(*this, setDownstreamLocalAddress(_))
      .WillByDefault(
          Invoke([this](const Network::Address::InstanceConstSharedPtr& downstream_local_address) {
            downstream_local_address_ = downstream_local_address;
          }));
  ON_CALL(*this, downstreamLocalAddress()).WillByDefault(ReturnRef(downstream_local_address_));
  ON_CALL(*this, setDownstreamDirectRemoteAddress(_))
      .WillByDefault(Invoke(
          [this](const Network::Address::InstanceConstSharedPtr& downstream_direct_remote_address) {
            downstream_direct_remote_address_ = downstream_direct_remote_address;
          }));
  ON_CALL(*this, downstreamDirectRemoteAddress())
      .WillByDefault(ReturnRef(downstream_direct_remote_address_));
  ON_CALL(*this, setDownstreamRemoteAddress(_))
      .WillByDefault(
          Invoke([this](const Network::Address::InstanceConstSharedPtr& downstream_remote_address) {
            downstream_remote_address_ = downstream_remote_address;
          }));
  ON_CALL(*this, downstreamRemoteAddress()).WillByDefault(ReturnRef(downstream_remote_address_));
  ON_CALL(*this, setDownstreamSslConnection(_))
      .WillByDefault(Invoke(
          [this](const auto& connection_info) { downstream_connection_info_ = connection_info; }));
  ON_CALL(*this, setUpstreamSslConnection(_))
      .WillByDefault(Invoke(
          [this](const auto& connection_info) { upstream_connection_info_ = connection_info; }));
  ON_CALL(*this, downstreamSslConnection()).WillByDefault(Invoke([this]() {
    return downstream_connection_info_;
  }));
  ON_CALL(*this, upstreamSslConnection()).WillByDefault(Invoke([this]() {
    return upstream_connection_info_;
  }));
  ON_CALL(*this, protocol()).WillByDefault(ReturnPointee(&protocol_));
  ON_CALL(*this, responseCode()).WillByDefault(ReturnPointee(&response_code_));
  ON_CALL(*this, responseCodeDetails()).WillByDefault(ReturnPointee(&response_code_details_));
  ON_CALL(*this, addBytesReceived(_)).WillByDefault(Invoke([this](uint64_t bytes_received) {
    bytes_received_ += bytes_received;
  }));
  ON_CALL(*this, bytesReceived()).WillByDefault(ReturnPointee(&bytes_received_));
  ON_CALL(*this, addBytesSent(_)).WillByDefault(Invoke([this](uint64_t bytes_sent) {
    bytes_sent_ += bytes_sent;
  }));
  ON_CALL(*this, bytesSent()).WillByDefault(ReturnPointee(&bytes_sent_));
  ON_CALL(*this, hasResponseFlag(_)).WillByDefault(Invoke([this](ResponseFlag flag) {
    return response_flags_ & flag;
  }));
  ON_CALL(*this, intersectResponseFlags(_)).WillByDefault(Invoke([this](uint64_t response_flags) {
    return (response_flags_ & response_flags) != 0;
  }));
  ON_CALL(*this, hasAnyResponseFlag()).WillByDefault(Invoke([this]() {
    return response_flags_ != 0;
  }));
  ON_CALL(*this, responseFlags()).WillByDefault(Return(response_flags_));
  ON_CALL(*this, upstreamHost()).WillByDefault(ReturnPointee(&host_));

  ON_CALL(*this, dynamicMetadata()).WillByDefault(ReturnRef(metadata_));
  ON_CALL(Const(*this), dynamicMetadata()).WillByDefault(ReturnRef(metadata_));
  ON_CALL(*this, filterState()).WillByDefault(ReturnRef(filter_state_));
  ON_CALL(Const(*this), filterState()).WillByDefault(ReturnRef(*filter_state_));
  ON_CALL(*this, upstreamFilterState()).WillByDefault(ReturnRef(upstream_filter_state_));
  ON_CALL(*this, setUpstreamFilterState(_))
      .WillByDefault(Invoke([this](const FilterStateSharedPtr& filter_state) {
        upstream_filter_state_ = filter_state;
      }));
  ON_CALL(*this, setRequestedServerName(_))
      .WillByDefault(Invoke([this](const absl::string_view requested_server_name) {
        requested_server_name_ = std::string(requested_server_name);
      }));
  ON_CALL(*this, requestedServerName()).WillByDefault(ReturnRef(requested_server_name_));
  ON_CALL(*this, setRouteName(_)).WillByDefault(Invoke([this](const absl::string_view route_name) {
    route_name_ = std::string(route_name);
  }));
  ON_CALL(*this, getRouteName()).WillByDefault(ReturnRef(route_name_));
  ON_CALL(*this, upstreamTransportFailureReason())
      .WillByDefault(ReturnRef(upstream_transport_failure_reason_));
}

MockStreamInfo::~MockStreamInfo() = default;

} // namespace StreamInfo
} // namespace Envoy
<|endoftext|>


<commit_before>/* bzflag
 * Copyright (c) 1993 - 2008 Tim Riker
 *
 * This package is free software;  you can redistribute it and/or
 * modify it under the terms of the license found in the file
 * named COPYING that should have accompanied this file.
 *
 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

#include "common.h"

#include <string.h>

#include "Pack.h"
#include "network.h"

#define	ADV(_b, _t)	((void*)(((char*)(_b)) + sizeof(_t)))

/* provided by htond.c */
void ntohd(register unsigned char *out, register const unsigned char *in, int count);
void htond(register unsigned char *out, register const unsigned char *in, int count);

//
// Unions
//

union floatintuni {
  float floatval;
  uint32_t intval;
};

//
// Buffer Overrun Checks
//

static bool Error = false;
static bool ErrorChecking = false;
static unsigned int Length = 0;

void nboUseErrorChecking(bool checking)
{
  ErrorChecking = checking;
}

bool nboGetBufferError()
{
  return Error;
}

void nboClearBufferError()
{
  Error = false;
}

void nboSetBufferLength(unsigned int length)
{
  Length = length;
}

unsigned int nboGetBufferLength()
{
  return Length;
}

//
// Packers
//

void*			nboPackUByte(void* b, uint8_t v)
{
  ::memcpy(b, &v, sizeof(uint8_t));
  return ADV(b, uint8_t);
}

void*			nboPackShort(void* b, int16_t v)
{
  const int16_t x = (int16_t)htons(v);
  ::memcpy(b, &x, sizeof(int16_t));
  return ADV(b, int16_t);
}

void*			nboPackInt(void* b, int32_t v)
{
  const int32_t x = (int32_t)htonl(v);
  ::memcpy(b, &x, sizeof(int32_t));
  return ADV(b, int32_t);
}

void*			nboPackUShort(void* b, uint16_t v)
{
  const uint16_t x = (uint16_t)htons(v);
  ::memcpy(b, &x, sizeof(uint16_t));
  return ADV(b, uint16_t);
}

void*			nboPackUInt(void* b, uint32_t v)
{
  const uint32_t x = (uint32_t)htonl(v);
  ::memcpy(b, &x, sizeof(uint32_t));
  return ADV(b, uint32_t);
}

void*			nboPackFloat(void* b, float v)
{
  // hope that float is a 4 byte IEEE 754 standard encoding
  floatintuni u;
  u.floatval = v;

  uint32_t x = (uint32_t)htonl(u.intval);
  ::memcpy(b, &x, sizeof(uint32_t));
  return ADV(b, uint32_t);
}

void*			nboPackDouble(void* b, double v)
{
  // hope the double is a 8 byte IEEE 754 standard encoding
  unsigned char *dptr = NULL;

  htond(dptr, (const unsigned char *)&v, 1);
  ::memcpy(b, &dptr, sizeof(uint64_t));
  return ADV(b, uint64_t);
}

void*			nboPackVector(void* b, const float *v)
{
  // hope that float is a 4 byte IEEE 754 standard encoding
  floatintuni u;
  uint32_t data[3];

  for (int i=0; i<3; i++) {
    u.floatval = v[i];
    data[i] = (uint32_t)htonl(u.intval);
  }

  ::memcpy( b, data, 3*sizeof(uint32_t));
  return (void*) (((char*)b)+3*sizeof(uint32_t));
}

void*			nboPackString(void* b, const void* m, int len)
{
  if (!m || len == 0) return b;
  ::memcpy(b, m, len);
  return (void*)((char*)b + len);
}

void*			nboPackStdString(void* b, const std::string& str)
{
  uint32_t strSize = (uint32_t)str.size();
  b = nboPackUInt(b, strSize);
  b = nboPackString(b, str.c_str(), strSize);
  return b;
}

//
// UnPackers
//

void*			nboUnpackUByte(void* b, uint8_t& v)
{
  if (ErrorChecking) {
    if (Length < sizeof(uint8_t)) {
      Error = true;
      v = 0;
      return b;
    } else {
      Length -= sizeof(uint8_t);
    }
  }
  ::memcpy(&v, b, sizeof(uint8_t));
  return ADV(b, uint8_t);
}

void*			nboUnpackShort(void* b, int16_t& v)
{
  if (ErrorChecking) {
    if (Length < sizeof(int16_t)) {
      Error = true;
      v = 0;
      return b;
    } else {
      Length -= sizeof(int16_t);
    }
  }
  int16_t x;
  ::memcpy(&x, b, sizeof(int16_t));
  v = (int16_t)ntohs(x);
  return ADV(b, int16_t);
}

void*			nboUnpackInt(void* b, int32_t& v)
{
  if (ErrorChecking) {
    if (Length < sizeof(int32_t)) {
      Error = true;
      v = 0;
      return b;
    } else {
      Length -= sizeof(int32_t);
    }
  }
  int32_t x;
  ::memcpy(&x, b, sizeof(int32_t));
  v = (int32_t)ntohl(x);
  return ADV(b, uint32_t);
}

void*			nboUnpackUShort(void* b, uint16_t& v)
{
  if (ErrorChecking) {
    if (Length < sizeof(uint16_t)) {
      Error = true;
      v = 0;
      return b;
    } else {
      Length -= sizeof(uint16_t);
    }
  }
  uint16_t x;
  ::memcpy(&x, b, sizeof(uint16_t));
  v = (uint16_t)ntohs(x);
  return ADV(b, uint16_t);
}

void*			nboUnpackUInt(void* b, uint32_t& v)
{
  if (ErrorChecking) {
    if (Length < sizeof(uint32_t)) {
      Error = true;
      v = 0;
      return b;
    } else {
      Length -= sizeof(uint32_t);
    }
  }
  uint32_t x;
  ::memcpy(&x, b, sizeof(uint32_t));
  v = (uint32_t)ntohl(x);
  return ADV(b, uint32_t);
}

void*			nboUnpackFloat(void* b, float& v)
{
  if (ErrorChecking) {
    if (Length < sizeof(float)) {
      Error = true;
      v = 0.0f;
      return b;
    } else {
      Length -= sizeof(float);
    }
  }

  // hope that float is a 4 byte IEEE 754 standard encoding
  uint32_t x;
  ::memcpy(&x, b, sizeof(uint32_t));
  floatintuni u;
  u.intval = (uint32_t)ntohl(x);
  v = u.floatval;
  return ADV(b, uint32_t);
}

void*			nboUnpackDouble(void* b, double& v)
{
  if (ErrorChecking) {
    if (Length < sizeof(double)) {
      Error = true;
      v = 0.0f;
      return b;
    } else {
      Length -= sizeof(double);
    }
  }

  // hope that double is 8 byte IEEE 754 standard encoding
  ntohd((unsigned char *)&v, (unsigned char *)b, 1);
  return ADV(b, uint64_t);
}

void*			nboUnpackVector(void* b, float *v)
{
  if (ErrorChecking) {
    if (Length < sizeof(float[3])) {
      Error = true;
      v[0] = v[1] = v[2] = 0.0f;
      return b;
    } else {
      Length -= sizeof(float[3]);
    }
  }

  // hope that float is a 4 byte IEEE 754 standard encoding
  uint32_t data[3];
  floatintuni u;
  ::memcpy( data, b, 3*sizeof(uint32_t));

  for (int i=0; i<3; i++) {
    u.intval = (uint32_t)ntohl(data[i]);
    v[i] = u.floatval;
  }

  return (void *) (((char*)b) + 3*sizeof(float));
}

void*			nboUnpackString(void* b, void* m, int len)
{
  if (!m || len == 0) return b;
  if (ErrorChecking) {
    if (Length < (unsigned int)len) {
      Error = true;
      ((char*)m)[0] = '\0';
      return b;
    } else {
      Length -= len;
    }
  }
  ::memcpy(m, b, len);
  return (void*)((char*)b + len);
}

void*			nboUnpackStdString(void* b, std::string& str)
{
  uint32_t strSize;
  b = nboUnpackUInt(b, strSize);
  char* buffer = new char[strSize + 1];
  b = nboUnpackString(b, buffer, strSize);
  buffer[strSize] = 0;
  str = buffer;
  delete[] buffer;
  if (ErrorChecking && Error) {
    str = "";
    return b;
  }
  return b;
}

void*			nboUnpackStdStringRaw(void* b, std::string& str)
{
  uint32_t strSize;
  b = nboUnpackUInt(b, strSize);
  char* buffer = new char[strSize + 1];
  b = nboUnpackString(b, buffer, strSize);
  buffer[strSize] = 0;
  str.resize(strSize);
  for (uint32_t i = 0; i < strSize; i++) {
    str[i] = buffer[i];
  }
  delete[] buffer;
  if (ErrorChecking && Error) {
    str = "";
    return b;
  }
  return b;
}

//
// Utilities
//

unsigned int nboStdStringPackSize(const std::string& str)
{
  return (unsigned int)(sizeof(uint32_t) + str.size());
}

// Local Variables: ***
// mode: C++ ***
// tab-width: 8 ***
// c-basic-offset: 2 ***
// indent-tabs-mode: t ***
// End: ***
// ex: shiftwidth=2 tabstop=8
<commit_msg>but I think this will work too...have htond copy directly into b.<commit_after>/* bzflag
 * Copyright (c) 1993 - 2008 Tim Riker
 *
 * This package is free software;  you can redistribute it and/or
 * modify it under the terms of the license found in the file
 * named COPYING that should have accompanied this file.
 *
 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

#include "common.h"

#include <string.h>

#include "Pack.h"
#include "network.h"

#define	ADV(_b, _t)	((void*)(((char*)(_b)) + sizeof(_t)))

/* provided by htond.c */
void ntohd(register unsigned char *out, register const unsigned char *in, int count);
void htond(register unsigned char *out, register const unsigned char *in, int count);

//
// Unions
//

union floatintuni {
  float floatval;
  uint32_t intval;
};

//
// Buffer Overrun Checks
//

static bool Error = false;
static bool ErrorChecking = false;
static unsigned int Length = 0;

void nboUseErrorChecking(bool checking)
{
  ErrorChecking = checking;
}

bool nboGetBufferError()
{
  return Error;
}

void nboClearBufferError()
{
  Error = false;
}

void nboSetBufferLength(unsigned int length)
{
  Length = length;
}

unsigned int nboGetBufferLength()
{
  return Length;
}

//
// Packers
//

void*			nboPackUByte(void* b, uint8_t v)
{
  ::memcpy(b, &v, sizeof(uint8_t));
  return ADV(b, uint8_t);
}

void*			nboPackShort(void* b, int16_t v)
{
  const int16_t x = (int16_t)htons(v);
  ::memcpy(b, &x, sizeof(int16_t));
  return ADV(b, int16_t);
}

void*			nboPackInt(void* b, int32_t v)
{
  const int32_t x = (int32_t)htonl(v);
  ::memcpy(b, &x, sizeof(int32_t));
  return ADV(b, int32_t);
}

void*			nboPackUShort(void* b, uint16_t v)
{
  const uint16_t x = (uint16_t)htons(v);
  ::memcpy(b, &x, sizeof(uint16_t));
  return ADV(b, uint16_t);
}

void*			nboPackUInt(void* b, uint32_t v)
{
  const uint32_t x = (uint32_t)htonl(v);
  ::memcpy(b, &x, sizeof(uint32_t));
  return ADV(b, uint32_t);
}

void*			nboPackFloat(void* b, float v)
{
  // hope that float is a 4 byte IEEE 754 standard encoding
  floatintuni u;
  u.floatval = v;

  uint32_t x = (uint32_t)htonl(u.intval);
  ::memcpy(b, &x, sizeof(uint32_t));
  return ADV(b, uint32_t);
}

void*			nboPackDouble(void* b, double v)
{
  // hope the double is a 8 byte IEEE 754 standard encoding
  htond(b, (const unsigned char *)&v, 1);
  return ADV(b, uint64_t);
}

void*			nboPackVector(void* b, const float *v)
{
  // hope that float is a 4 byte IEEE 754 standard encoding
  floatintuni u;
  uint32_t data[3];

  for (int i=0; i<3; i++) {
    u.floatval = v[i];
    data[i] = (uint32_t)htonl(u.intval);
  }

  ::memcpy( b, data, 3*sizeof(uint32_t));
  return (void*) (((char*)b)+3*sizeof(uint32_t));
}

void*			nboPackString(void* b, const void* m, int len)
{
  if (!m || len == 0) return b;
  ::memcpy(b, m, len);
  return (void*)((char*)b + len);
}

void*			nboPackStdString(void* b, const std::string& str)
{
  uint32_t strSize = (uint32_t)str.size();
  b = nboPackUInt(b, strSize);
  b = nboPackString(b, str.c_str(), strSize);
  return b;
}

//
// UnPackers
//

void*			nboUnpackUByte(void* b, uint8_t& v)
{
  if (ErrorChecking) {
    if (Length < sizeof(uint8_t)) {
      Error = true;
      v = 0;
      return b;
    } else {
      Length -= sizeof(uint8_t);
    }
  }
  ::memcpy(&v, b, sizeof(uint8_t));
  return ADV(b, uint8_t);
}

void*			nboUnpackShort(void* b, int16_t& v)
{
  if (ErrorChecking) {
    if (Length < sizeof(int16_t)) {
      Error = true;
      v = 0;
      return b;
    } else {
      Length -= sizeof(int16_t);
    }
  }
  int16_t x;
  ::memcpy(&x, b, sizeof(int16_t));
  v = (int16_t)ntohs(x);
  return ADV(b, int16_t);
}

void*			nboUnpackInt(void* b, int32_t& v)
{
  if (ErrorChecking) {
    if (Length < sizeof(int32_t)) {
      Error = true;
      v = 0;
      return b;
    } else {
      Length -= sizeof(int32_t);
    }
  }
  int32_t x;
  ::memcpy(&x, b, sizeof(int32_t));
  v = (int32_t)ntohl(x);
  return ADV(b, uint32_t);
}

void*			nboUnpackUShort(void* b, uint16_t& v)
{
  if (ErrorChecking) {
    if (Length < sizeof(uint16_t)) {
      Error = true;
      v = 0;
      return b;
    } else {
      Length -= sizeof(uint16_t);
    }
  }
  uint16_t x;
  ::memcpy(&x, b, sizeof(uint16_t));
  v = (uint16_t)ntohs(x);
  return ADV(b, uint16_t);
}

void*			nboUnpackUInt(void* b, uint32_t& v)
{
  if (ErrorChecking) {
    if (Length < sizeof(uint32_t)) {
      Error = true;
      v = 0;
      return b;
    } else {
      Length -= sizeof(uint32_t);
    }
  }
  uint32_t x;
  ::memcpy(&x, b, sizeof(uint32_t));
  v = (uint32_t)ntohl(x);
  return ADV(b, uint32_t);
}

void*			nboUnpackFloat(void* b, float& v)
{
  if (ErrorChecking) {
    if (Length < sizeof(float)) {
      Error = true;
      v = 0.0f;
      return b;
    } else {
      Length -= sizeof(float);
    }
  }

  // hope that float is a 4 byte IEEE 754 standard encoding
  uint32_t x;
  ::memcpy(&x, b, sizeof(uint32_t));
  floatintuni u;
  u.intval = (uint32_t)ntohl(x);
  v = u.floatval;
  return ADV(b, uint32_t);
}

void*			nboUnpackDouble(void* b, double& v)
{
  if (ErrorChecking) {
    if (Length < sizeof(double)) {
      Error = true;
      v = 0.0f;
      return b;
    } else {
      Length -= sizeof(double);
    }
  }

  // hope that double is 8 byte IEEE 754 standard encoding
  ntohd((unsigned char *)&v, (unsigned char *)b, 1);
  return ADV(b, uint64_t);
}

void*			nboUnpackVector(void* b, float *v)
{
  if (ErrorChecking) {
    if (Length < sizeof(float[3])) {
      Error = true;
      v[0] = v[1] = v[2] = 0.0f;
      return b;
    } else {
      Length -= sizeof(float[3]);
    }
  }

  // hope that float is a 4 byte IEEE 754 standard encoding
  uint32_t data[3];
  floatintuni u;
  ::memcpy( data, b, 3*sizeof(uint32_t));

  for (int i=0; i<3; i++) {
    u.intval = (uint32_t)ntohl(data[i]);
    v[i] = u.floatval;
  }

  return (void *) (((char*)b) + 3*sizeof(float));
}

void*			nboUnpackString(void* b, void* m, int len)
{
  if (!m || len == 0) return b;
  if (ErrorChecking) {
    if (Length < (unsigned int)len) {
      Error = true;
      ((char*)m)[0] = '\0';
      return b;
    } else {
      Length -= len;
    }
  }
  ::memcpy(m, b, len);
  return (void*)((char*)b + len);
}

void*			nboUnpackStdString(void* b, std::string& str)
{
  uint32_t strSize;
  b = nboUnpackUInt(b, strSize);
  char* buffer = new char[strSize + 1];
  b = nboUnpackString(b, buffer, strSize);
  buffer[strSize] = 0;
  str = buffer;
  delete[] buffer;
  if (ErrorChecking && Error) {
    str = "";
    return b;
  }
  return b;
}

void*			nboUnpackStdStringRaw(void* b, std::string& str)
{
  uint32_t strSize;
  b = nboUnpackUInt(b, strSize);
  char* buffer = new char[strSize + 1];
  b = nboUnpackString(b, buffer, strSize);
  buffer[strSize] = 0;
  str.resize(strSize);
  for (uint32_t i = 0; i < strSize; i++) {
    str[i] = buffer[i];
  }
  delete[] buffer;
  if (ErrorChecking && Error) {
    str = "";
    return b;
  }
  return b;
}

//
// Utilities
//

unsigned int nboStdStringPackSize(const std::string& str)
{
  return (unsigned int)(sizeof(uint32_t) + str.size());
}

// Local Variables: ***
// mode: C++ ***
// tab-width: 8 ***
// c-basic-offset: 2 ***
// indent-tabs-mode: t ***
// End: ***
// ex: shiftwidth=2 tabstop=8
<|endoftext|>


<commit_before>/*
 * Copyright (c) 2011, Michael Feathers, James Grenning and Bas Vodde
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the <organization> nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifdef INCLUDE_GTEST_TESTS
#undef new

#include "gtest/gtest.h"

static bool g_GTestEqual_has_been_called = false;
TEST(GTestSimpleTest, GTestEqual)
{
	EXPECT_EQ(1, 1);
	g_GTestEqual_has_been_called = true;
}

TEST(GTestSimpleTest, GTestAssertEq)
{
	ASSERT_EQ(1, 1);
}

TEST(GTestSimpleTest, GTestExpectTrue)
{
	EXPECT_TRUE(true);
}

TEST(GTestSimpleTest, GTestAssertTrue)
{
	ASSERT_TRUE(true);
}

TEST(GTestSimpleTest, GTestExpectFalse)
{
	EXPECT_FALSE(false);
}

TEST(GTestSimpleTest, GTestExpectStreq)
{
	EXPECT_STREQ("hello world", "hello world");
}

/* Death tests are IMHO not a good idea at all. But for compatibility reason, we'll support it */

static void crashMe ()
{
	fprintf(stderr, "Crash me!");
	*((int*) 0) = 10;
}

TEST(GTestSimpleTest, GTestDeathTest)
{
	ASSERT_DEATH(crashMe(), "Crash me!");
}

#undef TEST

#include "CppUTest/TestHarness.h"
#include "CppUTest/TestOutput.h"
#include "CppUTest/TestTestingFixture.h"

TEST_GROUP(gtest)
{
};

TEST(gtest, SimpleGoogleTestExists)
{
	TestRegistry* registry = TestRegistry::getCurrentRegistry();
	CHECK(registry->findTestWithName("GTestEqual"));
}

TEST(gtest, SimpleGoogleTestGroupExists)
{
	TestRegistry* registry = TestRegistry::getCurrentRegistry();
	CHECK(registry->findTestWithGroup("GTestSimpleTest"));
}

TEST(gtest, SimpleGoogleTestGetCalled)
{
	StringBufferTestOutput output;
	TestResult result(output);
	TestPlugin plugin("dummy");

	TestRegistry* registry = TestRegistry::getCurrentRegistry();
	UtestShell * shell = registry->findTestWithName("GTestEqual");
	g_GTestEqual_has_been_called = false;
	shell->runOneTest(&plugin, result);

	CHECK(g_GTestEqual_has_been_called);
}

static bool afterCheck;

static void _failMethodEXPECT_EQ()
{
	EXPECT_EQ(1, 2);
	afterCheck = true;
}

static void _failMethodASSERT_EQ()
{
	ASSERT_EQ(1, 2);
	afterCheck = true;
}

static void _failMethodEXPECT_TRUE()
{
	EXPECT_TRUE(false);
	afterCheck = true;
}

static void _failMethodASSERT_TRUE()
{
	ASSERT_TRUE(false);
	afterCheck = true;
}

static void _failMethodEXPECT_FALSE()
{
	EXPECT_FALSE(true);
	afterCheck = true;
}

static void _failMethodEXPECT_STREQ()
{
	EXPECT_STREQ("hello", "world");
	afterCheck = true;
}

TEST_GROUP(gtestMacros)
{
	TestTestingFixture* fixture;
	void setup()
	{
		fixture = new TestTestingFixture();
		afterCheck = false;
	}
	void teardown()
	{
		delete fixture;
	}

	void testFailureWith(void(*method)())
	{
		fixture->setTestFunction(method);
		fixture->runAllTests();
		LONGS_EQUAL(1, fixture->getFailureCount());
		CHECK(!afterCheck);
	}

};

TEST(gtestMacros, EXPECT_EQFails)
{
	testFailureWith(_failMethodEXPECT_EQ);
}

TEST(gtestMacros, EXPECT_TRUEFails)
{
	testFailureWith(_failMethodEXPECT_TRUE);
}

TEST(gtestMacros, EXPECT_FALSEFails)
{
	testFailureWith(_failMethodEXPECT_FALSE);
}

TEST(gtestMacros, EXPECT_STREQFails)
{
	testFailureWith(_failMethodEXPECT_STREQ);
}

TEST(gtestMacros, ASSERT_EQFails)
{
	testFailureWith(_failMethodASSERT_EQ);
}

TEST(gtestMacros, ASSERT_TRUEFails)
{
	testFailureWith(_failMethodASSERT_TRUE);
}

#endif
<commit_msg>Use the GTest include instead of the gtest one<commit_after>/*
 * Copyright (c) 2011, Michael Feathers, James Grenning and Bas Vodde
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the <organization> nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifdef INCLUDE_GTEST_TESTS
#undef new

#include "CppuTestExt/GTest.h"
#include "CppuTestExt/GMock.h"

static bool g_GTestEqual_has_been_called = false;
TEST(GTestSimpleTest, GTestEqual)
{
	EXPECT_EQ(1, 1);
	g_GTestEqual_has_been_called = true;
}

TEST(GTestSimpleTest, GTestAssertEq)
{
	ASSERT_EQ(1, 1);
}

TEST(GTestSimpleTest, GTestExpectTrue)
{
	EXPECT_TRUE(true);
}

TEST(GTestSimpleTest, GTestAssertTrue)
{
	ASSERT_TRUE(true);
}

TEST(GTestSimpleTest, GTestExpectFalse)
{
	EXPECT_FALSE(false);
}

TEST(GTestSimpleTest, GTestExpectStreq)
{
	EXPECT_STREQ("hello world", "hello world");
}

/* Death tests are IMHO not a good idea at all. But for compatibility reason, we'll support it */

static void crashMe ()
{
	fprintf(stderr, "Crash me!");
	*((int*) 0) = 10;
}

TEST(GTestSimpleTest, GTestDeathTest)
{
	ASSERT_DEATH(crashMe(), "Crash me!");
}

#undef TEST

#include "CppUTest/TestHarness.h"
#include "CppUTest/TestOutput.h"
#include "CppUTest/TestTestingFixture.h"

TEST_GROUP(gtest)
{
};

TEST(gtest, SimpleGoogleTestExists)
{
	TestRegistry* registry = TestRegistry::getCurrentRegistry();
	CHECK(registry->findTestWithName("GTestEqual"));
}

TEST(gtest, SimpleGoogleTestGroupExists)
{
	TestRegistry* registry = TestRegistry::getCurrentRegistry();
	CHECK(registry->findTestWithGroup("GTestSimpleTest"));
}

TEST(gtest, SimpleGoogleTestGetCalled)
{
	StringBufferTestOutput output;
	TestResult result(output);
	TestPlugin plugin("dummy");

	TestRegistry* registry = TestRegistry::getCurrentRegistry();
	UtestShell * shell = registry->findTestWithName("GTestEqual");
	g_GTestEqual_has_been_called = false;
	shell->runOneTest(&plugin, result);

	CHECK(g_GTestEqual_has_been_called);
}

static bool afterCheck;

static void _failMethodEXPECT_EQ()
{
	EXPECT_EQ(1, 2);
	afterCheck = true;
}

static void _failMethodASSERT_EQ()
{
	ASSERT_EQ(1, 2);
	afterCheck = true;
}

static void _failMethodEXPECT_TRUE()
{
	EXPECT_TRUE(false);
	afterCheck = true;
}

static void _failMethodASSERT_TRUE()
{
	ASSERT_TRUE(false);
	afterCheck = true;
}

static void _failMethodEXPECT_FALSE()
{
	EXPECT_FALSE(true);
	afterCheck = true;
}

static void _failMethodEXPECT_STREQ()
{
	EXPECT_STREQ("hello", "world");
	afterCheck = true;
}

TEST_GROUP(gtestMacros)
{
	TestTestingFixture* fixture;
	void setup()
	{
		fixture = new TestTestingFixture();
		afterCheck = false;
	}
	void teardown()
	{
		delete fixture;
	}

	void testFailureWith(void(*method)())
	{
		fixture->setTestFunction(method);
		fixture->runAllTests();
		LONGS_EQUAL(1, fixture->getFailureCount());
		CHECK(!afterCheck);
	}

};

TEST(gtestMacros, EXPECT_EQFails)
{
	testFailureWith(_failMethodEXPECT_EQ);
}

TEST(gtestMacros, EXPECT_TRUEFails)
{
	testFailureWith(_failMethodEXPECT_TRUE);
}

TEST(gtestMacros, EXPECT_FALSEFails)
{
	testFailureWith(_failMethodEXPECT_FALSE);
}

TEST(gtestMacros, EXPECT_STREQFails)
{
	testFailureWith(_failMethodEXPECT_STREQ);
}

TEST(gtestMacros, ASSERT_EQFails)
{
	testFailureWith(_failMethodASSERT_EQ);
}

TEST(gtestMacros, ASSERT_TRUEFails)
{
	testFailureWith(_failMethodASSERT_TRUE);
}

#endif
<|endoftext|>


<commit_before>#include <gamelib/core/common.h>
#include <gamelib/core/linuxinformation.h>

#include <gtest/gtest.h>

using namespace gamelib::core;

class LinuxInformationTest : public testing::Test
{
protected:
	virtual void SetUp() override
	{
		this->osInfo = new LinuxInformation();
	}

	virtual void TearDown() override
	{
		delete this->osInfo;
	}

	OSInformation * osInfo = nullptr;
};

TEST_F(LinuxInformationTest, testEnvMethodConsistent) {
	// test that the stored char is not the same
	std::string home = osInfo->getEnv("HOME");
	std::string path = osInfo->getEnv("PATH");

	EXPECT_NE(home, path);
}
<commit_msg>test/core: use better name for test case<commit_after>#include <gamelib/core/common.h>
#include <gamelib/core/linuxinformation.h>

#include <gtest/gtest.h>

using namespace gamelib::core;

class LinuxInformationTest : public testing::Test
{
protected:
	virtual void SetUp() override
	{
		this->osInfo = new LinuxInformation();
	}

	virtual void TearDown() override
	{
		delete this->osInfo;
	}

	OSInformation * osInfo = nullptr;
};

TEST_F(LinuxInformationTest, getEnvConsistency) {
	// test that the stored char is not the same
	std::string home = osInfo->getEnv("HOME");
	std::string path = osInfo->getEnv("PATH");

	EXPECT_NE(home, path);
}
<|endoftext|>


<commit_before>#include "unittests.h"
#include "serialport.h"

#include <QtCore/QTimer>
#include <QtCore/QStringList>

enum {
    RATES_COUNT    = 2,
    DATABITS_COUNT = 1,
    PARITY_COUNT   = 5,
    STOPBITS_COUNT = 2,
    FLOW_COUNT     = 3
};

static const SerialPort::Rate vratesarray[RATES_COUNT] = {
    SerialPort::Rate9600,
    SerialPort::Rate115200
};
static const char *sratesarray[] = {
    "9600\0",
    "115200\0"
};

static const SerialPort::DataBits vdatabitsarray[DATABITS_COUNT] = {
    SerialPort::Data8
};
static const char *sdatabitsarray[] = {
    "8\0"
};

static const SerialPort::Parity vparitysarray[PARITY_COUNT] = {
    SerialPort::NoParity,
    SerialPort::EvenParity,
    SerialPort::OddParity,
    SerialPort::SpaceParity,
    SerialPort::MarkParity
};
static const char *sparitysarray[] = {
    "none\0",
    "even\0",
    "odd\0",
    "space\0",
    "mark\0"
};

static const SerialPort::StopBits vstopbitsarray[STOPBITS_COUNT] = {
    SerialPort::OneStop,
    SerialPort::TwoStop
};
static const char *sstopbitsarray[] = {
    "one\0",
    "two\0"
};

static const SerialPort::FlowControl vflowsarray[FLOW_COUNT] = {
    SerialPort::NoFlowControl,
    SerialPort::HardwareControl,
    SerialPort::SoftwareControl
};
static const char *sflowsarray[] = {
    "none\0",
    "hardware\0",
    "software\0"
};

/* Public methods */

UnitTestIO::UnitTestIO(Logger *logger, QObject *parent)
    : UnitTestBase(UnitTestBase::IOUnitId, logger, parent)
    , m_rateIterator(0)
    , m_databitsIterator(0)
    , m_parityIterator(0)
    , m_stopbitsIterator(0)
    , m_flowIterator(0)
    , m_bytesWrite(0)
    , m_bytesRead(0)
{
    m_name = QString(tr("IO Test"));
    m_description = QString(tr("\"IO Test\" designed to test the I/O between the two ports\n"
                               "Source port sends a data packet to the destination port,\n"
                               "that reads the packet.\n"
                               "  The default packet size is 500 bytes, the size can be changed\n"
                               "programmatically by changing the value of the\n"
                               "variable TransferBytesCount. Also, before sending the package\n"
                               "is filled with a random value.\n"
                               "  Both ports after each transaction, change their parameters:\n"
                               "speed, number of data bits, parity, number of stop bits,\n"
                               "flow regime, until the end all enumerated parameters.\n"
                               "After each transaction is recorded in a log the contents of the\n"
                               "sent and received packet, and check their size. If the packet\n"
                               "sizes are different, the test is aborted with an error which is\n"
                               "recorded in the log.\n"
                               ));

    m_srcPort = new SerialPort(this);
    m_dstPort = new SerialPort(this);
}

/* Public slots */

void UnitTestIO::start(bool first)
{
    if (first) {
        QString header(tr("\n[ Test: ID#%1, Name: %2 ]\n%3\n\n"));
        header = header
                .arg(m_id)
                .arg(m_name)
                .arg(QString("timestamp"));/*.arg(UnitTestManager::timestamp());*/

        m_logger->addContent(header);

        m_srcPort->setPort(m_srcPortName);
        m_dstPort->setPort(m_dstPortName);

        if (!(open(UnitTestBase::SrcPort) && open(UnitTestBase::DstPort))) {
            emit error();
            return;
        } else {
            QString content(tr("\nSource and destination ports is opened.\n"));
            m_logger->addContent(content);
        }

        m_rateIterator = 0;
        m_databitsIterator = 0;
        m_parityIterator = 0;
        m_stopbitsIterator = 0;
        m_flowIterator = 0;
    }

    transaction();
}

/* Private slots */

void UnitTestIO::procSingleShot()
{
    QByteArray data = m_dstPort->readAll();
    m_bytesRead = data.count();

    QString content(tr("= write: %1 read: %2 =\n"));
    content = content
            .arg(m_bytesWrite)
            .arg(m_bytesRead);
    m_logger->addContent(content);

    if (m_bytesWrite != m_bytesRead) {
        content = QString(tr("\nError: Mismatch of write and read bytes.\n"));
        m_logger->addContent(content);
        close(UnitTestBase::SrcPort);
        close(UnitTestBase::DstPort);
        emit error();
        return;
    }

    ++m_rateIterator;
    if (m_rateIterator == RATES_COUNT) {
        m_rateIterator = 0;

        ++m_databitsIterator;
        if (m_databitsIterator == DATABITS_COUNT) {
            m_databitsIterator = 0;

            ++m_parityIterator;
            if (m_parityIterator == PARITY_COUNT) {
                m_parityIterator = 0;

                ++m_stopbitsIterator;
                if (m_stopbitsIterator == STOPBITS_COUNT) {
                    m_stopbitsIterator = 0;

                    ++m_flowIterator;
                    if (m_flowIterator == FLOW_COUNT) {
                        m_flowIterator = 0;

                        close(UnitTestBase::SrcPort);
                        close(UnitTestBase::DstPort);
                        emit finished();
                        return;
                    }
                }
            }
        }
    }

    transaction();
}

void UnitTestIO::transaction()
{
    if (!(configure(UnitTestBase::SrcPort) && configure(UnitTestBase::DstPort))) {
        emit error();
        return;
    }

    QString content(tr("\nrate    : %1"
                       "\ndatabits: %2"
                       "\npatity  : %3"
                       "\nstopbits: %4"
                       "\nflow    : %5\n"));

    content = content
            .arg(QString(sratesarray[m_rateIterator]))
            .arg(QString(sdatabitsarray[m_databitsIterator]))
            .arg(QString(sparitysarray[m_parityIterator]))
            .arg(QString(sstopbitsarray[m_stopbitsIterator]))
            .arg(QString(sflowsarray[m_flowIterator]));

    m_logger->addContent(content);

    QByteArray data(TransferBytesCount, qrand());
    m_bytesWrite = m_srcPort->write(data);

    QTimer::singleShot(TransactionMsecDelay, this, SLOT(procSingleShot()));
}

/* Private */

bool UnitTestIO::open(DirPorts dir)
{
    SerialPort *port = (dir == UnitTestBase::SrcPort) ?
                m_srcPort : m_dstPort;
    QIODevice::OpenMode mode = (dir == UnitTestBase::SrcPort) ?
                QIODevice::WriteOnly : QIODevice::ReadOnly;

    QString error("\nError: Can\'t open port %1\n");
    if (!port->open(mode)) {
        error = error.arg(port->portName());
        m_logger->addContent(error);
        return false;
    }
    return true;
}

bool UnitTestIO::configure(DirPorts dir)
{
    SerialPort *port = (dir == UnitTestBase::SrcPort) ?
                m_srcPort : m_dstPort;

    if (!(port->setRate(vratesarray[m_rateIterator])
          && port->setDataBits(vdatabitsarray[m_databitsIterator])
          && port->setParity(vparitysarray[m_parityIterator])
          && port->setStopBits(vstopbitsarray[m_stopbitsIterator])
          && port->setFlowControl(vflowsarray[m_flowIterator]))) {

        QString error("\nError: Can\'t configure port %1\n");
        error = error.arg(port->portName());
        m_logger->addContent(error);
        return false;
    }
    return true;
}

void UnitTestIO::close(DirPorts dir)
{
    if (dir == UnitTestBase::SrcPort) {
        if (m_srcPort->isOpen())
            m_srcPort->close();
    } else {
        if (m_dstPort->isOpen())
            m_dstPort->close();
    }
}

<commit_msg>/tests/guidevtest: For test "IO test" implemented in a log record of the transmitted/received data packet. In this case, the data in the log are sorted in a table of 32 characters.<commit_after>#include "unittests.h"
#include "serialport.h"

#include <QtCore/QTimer>
#include <QtCore/QStringList>

enum {
    RATES_COUNT    = 2,
    DATABITS_COUNT = 1,
    PARITY_COUNT   = 5,
    STOPBITS_COUNT = 2,
    FLOW_COUNT     = 3
};

static const SerialPort::Rate vratesarray[RATES_COUNT] = {
    SerialPort::Rate9600,
    SerialPort::Rate115200
};
static const char *sratesarray[] = {
    "9600\0",
    "115200\0"
};

static const SerialPort::DataBits vdatabitsarray[DATABITS_COUNT] = {
    SerialPort::Data8
};
static const char *sdatabitsarray[] = {
    "8\0"
};

static const SerialPort::Parity vparitysarray[PARITY_COUNT] = {
    SerialPort::NoParity,
    SerialPort::EvenParity,
    SerialPort::OddParity,
    SerialPort::SpaceParity,
    SerialPort::MarkParity
};
static const char *sparitysarray[] = {
    "none\0",
    "even\0",
    "odd\0",
    "space\0",
    "mark\0"
};

static const SerialPort::StopBits vstopbitsarray[STOPBITS_COUNT] = {
    SerialPort::OneStop,
    SerialPort::TwoStop
};
static const char *sstopbitsarray[] = {
    "one\0",
    "two\0"
};

static const SerialPort::FlowControl vflowsarray[FLOW_COUNT] = {
    SerialPort::NoFlowControl,
    SerialPort::HardwareControl,
    SerialPort::SoftwareControl
};
static const char *sflowsarray[] = {
    "none\0",
    "hardware\0",
    "software\0"
};

static QString split_on_table(const QByteArray &data, int tablewidth)
{
    QString result;
    int datacount = data.count();
    int i = 0;

    while (i < datacount) {
        result.append(data.mid(i, tablewidth).toHex());
        result.append('\n');
        i += tablewidth;
    }
    return result;
}

/* Public methods */

UnitTestIO::UnitTestIO(Logger *logger, QObject *parent)
    : UnitTestBase(UnitTestBase::IOUnitId, logger, parent)
    , m_rateIterator(0)
    , m_databitsIterator(0)
    , m_parityIterator(0)
    , m_stopbitsIterator(0)
    , m_flowIterator(0)
    , m_bytesWrite(0)
    , m_bytesRead(0)
{
    m_name = QString(tr("IO Test"));
    m_description = QString(tr("\"IO Test\" designed to test the I/O between the two ports\n"
                               "Source port sends a data packet to the destination port,\n"
                               "that reads the packet.\n"
                               "  The default packet size is 500 bytes, the size can be changed\n"
                               "programmatically by changing the value of the\n"
                               "variable TransferBytesCount. Also, before sending the package\n"
                               "is filled with a random value.\n"
                               "  Both ports after each transaction, change their parameters:\n"
                               "speed, number of data bits, parity, number of stop bits,\n"
                               "flow regime, until the end all enumerated parameters.\n"
                               "After each transaction is recorded in a log the contents of the\n"
                               "sent and received packet, and check their size. If the packet\n"
                               "sizes are different, the test is aborted with an error which is\n"
                               "recorded in the log.\n"
                               ));

    m_srcPort = new SerialPort(this);
    m_dstPort = new SerialPort(this);
}

/* Public slots */

void UnitTestIO::start(bool first)
{
    if (first) {
        QString header(tr("\n[ Test: ID#%1, Name: %2 ]\n%3\n\n"));
        header = header
                .arg(m_id)
                .arg(m_name)
                .arg(QString("timestamp"));/*.arg(UnitTestManager::timestamp());*/

        m_logger->addContent(header);

        m_srcPort->setPort(m_srcPortName);
        m_dstPort->setPort(m_dstPortName);

        if (!(open(UnitTestBase::SrcPort) && open(UnitTestBase::DstPort))) {
            emit error();
            return;
        } else {
            QString content(tr("\nSource and destination ports is opened.\n"));
            m_logger->addContent(content);
        }

        m_rateIterator = 0;
        m_databitsIterator = 0;
        m_parityIterator = 0;
        m_stopbitsIterator = 0;
        m_flowIterator = 0;
    }

    transaction();
}

/* Private slots */

void UnitTestIO::procSingleShot()
{
    QByteArray data = m_dstPort->readAll();

    QString content("r:\n%1\n");
    content = content.arg(split_on_table(data, 32));
    m_logger->addContent(content);

    m_bytesRead = data.count();

    content = QString(tr("= write: %1 read: %2 =\n"));
    content = content
            .arg(m_bytesWrite)
            .arg(m_bytesRead);
    m_logger->addContent(content);

    if (m_bytesWrite != m_bytesRead) {
        content = QString(tr("\nError: Mismatch of write and read bytes.\n"));
        m_logger->addContent(content);
        close(UnitTestBase::SrcPort);
        close(UnitTestBase::DstPort);
        emit error();
        return;
    }

    ++m_rateIterator;
    if (m_rateIterator == RATES_COUNT) {
        m_rateIterator = 0;

        ++m_databitsIterator;
        if (m_databitsIterator == DATABITS_COUNT) {
            m_databitsIterator = 0;

            ++m_parityIterator;
            if (m_parityIterator == PARITY_COUNT) {
                m_parityIterator = 0;

                ++m_stopbitsIterator;
                if (m_stopbitsIterator == STOPBITS_COUNT) {
                    m_stopbitsIterator = 0;

                    ++m_flowIterator;
                    if (m_flowIterator == FLOW_COUNT) {
                        m_flowIterator = 0;

                        close(UnitTestBase::SrcPort);
                        close(UnitTestBase::DstPort);
                        emit finished();
                        return;
                    }
                }
            }
        }
    }

    transaction();
}

void UnitTestIO::transaction()
{
    if (!(configure(UnitTestBase::SrcPort) && configure(UnitTestBase::DstPort))) {
        emit error();
        return;
    }

    QString content(tr("\nrate    : %1"
                       "\ndatabits: %2"
                       "\npatity  : %3"
                       "\nstopbits: %4"
                       "\nflow    : %5\n"));

    content = content
            .arg(QString(sratesarray[m_rateIterator]))
            .arg(QString(sdatabitsarray[m_databitsIterator]))
            .arg(QString(sparitysarray[m_parityIterator]))
            .arg(QString(sstopbitsarray[m_stopbitsIterator]))
            .arg(QString(sflowsarray[m_flowIterator]));

    m_logger->addContent(content);

    QByteArray data(TransferBytesCount, qrand());
    m_bytesWrite = m_srcPort->write(data);

    content = "w:\n%1\n";
    content = content.arg(split_on_table(data, 32));
    m_logger->addContent(content);

    QTimer::singleShot(TransactionMsecDelay, this, SLOT(procSingleShot()));
}

/* Private */

bool UnitTestIO::open(DirPorts dir)
{
    SerialPort *port = (dir == UnitTestBase::SrcPort) ?
                m_srcPort : m_dstPort;
    QIODevice::OpenMode mode = (dir == UnitTestBase::SrcPort) ?
                QIODevice::WriteOnly : QIODevice::ReadOnly;

    QString error("\nError: Can\'t open port %1\n");
    if (!port->open(mode)) {
        error = error.arg(port->portName());
        m_logger->addContent(error);
        return false;
    }
    return true;
}

bool UnitTestIO::configure(DirPorts dir)
{
    SerialPort *port = (dir == UnitTestBase::SrcPort) ?
                m_srcPort : m_dstPort;

    if (!(port->setRate(vratesarray[m_rateIterator])
          && port->setDataBits(vdatabitsarray[m_databitsIterator])
          && port->setParity(vparitysarray[m_parityIterator])
          && port->setStopBits(vstopbitsarray[m_stopbitsIterator])
          && port->setFlowControl(vflowsarray[m_flowIterator]))) {

        QString error("\nError: Can\'t configure port %1\n");
        error = error.arg(port->portName());
        m_logger->addContent(error);
        return false;
    }
    return true;
}

void UnitTestIO::close(DirPorts dir)
{
    if (dir == UnitTestBase::SrcPort) {
        if (m_srcPort->isOpen())
            m_srcPort->close();
    } else {
        if (m_dstPort->isOpen())
            m_dstPort->close();
    }
}

<|endoftext|>


<commit_before>#include "utils.hpp"
#include <boost/graph/metis.hpp>
#include <boost/graph/distributed/page_rank.hpp>

struct Node {
    Node() {}
    Node(const std::string& name) : name(name) {}
    float pagerank;
    std::string name;
    template<typename Archiver>
    void serialize(Archiver &ar, const unsigned int) {
        ar & name & pagerank;
    }
};

template <typename Graph>
struct GraphFixture {
    typedef typename property_map<Graph, float Node::*>::type VertexFloatMap;
    typedef typename graph_traits<Graph>::vertex_descriptor Vertex;

    GraphFixture(): g() {
        prm = get(&Node::pagerank, g);

        std::ifstream in("itnet.metis");
        boost::graph::metis_reader reader(in);
        Graph g(reader.begin(), reader.end(), reader.num_vertices());
        synchronize(g.process_group());
    }

    bool is_root() {
        return (process_id(g.process_group()) == 0);
    }

    Graph g;
    VertexFloatMap prm;
};

typedef adjacency_list <vecS, distributedS<mpi_process_group, vecS>, directedS, Node> Digraph;
typedef adjacency_list <vecS, distributedS<mpi_process_group, vecS>, bidirectionalS, Node> Bigraph;
// typedef compressed_sparse_row_graph<directedS, Node, no_property, no_property, distributedS<mpi_process_group> > CSRDigraph;

DECLARE_TYPE_NAME(Digraph);
DECLARE_TYPE_NAME(Bigraph);

typedef mpl::list<Digraph, Bigraph> GraphTypes;

BOOST_AUTO_TEST_CASE_TEMPLATE(ScalabilityTest, G, GraphTypes)
{
    benchmark::event_list events;
    GraphFixture<G> f;

    for (size_t i = 0; i < 3; ++i) {
        BENCHMARK(events, page_rank(f.g, f.prm));
    }

    log_average_values(std::cout, "PageRank", GET_TYPE_NAME(f.g), events, f.is_root());
}

int BOOST_TEST_CALL_DECL main(int argc, char *argv[])
{
    mpi::environment env(argc, argv);
    return ::boost::unit_test::unit_test_main(&init_unit_test, argc, argv);
}
<commit_msg>Separate METIS and CSV fixture (the latter is WIP)<commit_after>#include "utils.hpp"
#include <boost/graph/metis.hpp>
#include <boost/graph/distributed/page_rank.hpp>

struct Node {
    float pagerank;
    template<typename Archiver>
    void serialize(Archiver &ar, const unsigned int) {
        ar & pagerank;
    }
};

template <typename Graph>
class CSVFixture
{
public:
    CSVFixture() {
    }
    virtual ~CSVFixture() {
    }
};

template <typename Graph>
class METISFixture
{
    typedef typename property_map<Graph, float Node::*>::type VertexFloatMap;
    typedef typename graph_traits<Graph>::vertex_descriptor Vertex;

    Graph *g;
    VertexFloatMap prm;

public:
    METISFixture() {
        ifstream in("/Users/carmine/Desktop/itnet.metis");
        graph::metis_reader reader(in);
        g = new Graph(reader.begin(), reader.end(), reader.num_vertices());
        prm = get(&Node::pagerank, graph());
    }

    virtual ~METISFixture() {
        delete g;
    }

    bool is_root() {
        return (process_id(graph().process_group()) == 0);
    }

    Graph& graph() {
        return *g;
    }

    VertexFloatMap& pagerank_map() {
        return prm;
    }
};

typedef adjacency_list <vecS, distributedS<mpi_process_group, vecS>, directedS, Node> Digraph;
typedef adjacency_list <vecS, distributedS<mpi_process_group, vecS>, bidirectionalS, Node> Bigraph;
typedef compressed_sparse_row_graph<directedS, Node, no_property, no_property, distributedS<mpi_process_group> > CSRDigraph;

DECLARE_TYPE_NAME(Digraph);
DECLARE_TYPE_NAME(Bigraph);
DECLARE_TYPE_NAME(CSRDigraph);

typedef mpl::list<Digraph, Bigraph> GraphTypes; // PageRank doesn't accept CSR graphs

BOOST_AUTO_TEST_CASE_TEMPLATE(ScalabilityTest, G, GraphTypes)
{
    benchmark::event_list events;
    METISFixture<G> f;

    BENCHMARK(events, page_rank(f.graph(), f.pagerank_map()));

    log_average_values(std::cout, "PageRank", GET_TYPE_NAME(f.graph()), events, f.is_root());
}

int BOOST_TEST_CALL_DECL main(int argc, char *argv[])
{
    mpi::environment env(argc, argv);
    return ::boost::unit_test::unit_test_main(&init_unit_test, argc, argv);
}
<|endoftext|>


<commit_before>#include "catch.hpp"

#include <utility>
#include <type_traits>
#include <iterator>
#include <algorithm>

#include <member_iterator.hpp>

#include <forward_list>

TEST_CASE("member_iterator based on ForwardIterator", "[member_iterator]")
{
    struct mock
    {
        char c;
        int i;
    };

    std::forward_list<mock> mocklist{{'a', 1}, {'b', 2}, {'c', 3}};

    typedef helene::
        member_iterator<int, mock, std::forward_list<mock>::iterator, &mock::i>
            mocklist_iterator_type;

    mocklist_iterator_type beg_it = mocklist.begin();
    mocklist_iterator_type end_it = mocklist.end();

    ////////////////////////////////////////////////////////////////////////////
    // Iterator concept
    SECTION("construction")
    {
        auto elem = *beg_it;
        mocklist_iterator_type cop_it = beg_it;
        mocklist_iterator_type mov_it = std::move(beg_it);

        REQUIRE(*mov_it == elem);
        REQUIRE(cop_it == mov_it);
    }

    SECTION("assignment")
    {
        mocklist_iterator_type cop_it = beg_it;
        cop_it = end_it;

        REQUIRE(cop_it == end_it);
    }

    SECTION("move assignment")
    {
        mocklist_iterator_type an_it = beg_it;
        mocklist_iterator_type another_it = end_it;

        another_it = std::move(an_it);

        REQUIRE(another_it == beg_it);
        REQUIRE(*another_it == *beg_it);
    }

    SECTION("swappable")
    {
        using std::swap;

        mocklist_iterator_type beg_it2 = beg_it;
        mocklist_iterator_type end_it2 = end_it;

        swap(beg_it2, end_it2);

        REQUIRE(beg_it2 == end_it);
        REQUIRE(end_it2 == beg_it);
    }

    SECTION("traits")
    {
        std::iterator_traits<mocklist_iterator_type>::value_type i = 20;
        std::iterator_traits<mocklist_iterator_type>::difference_type j = -2;
        std::iterator_traits<mocklist_iterator_type>::reference k = i;
        std::iterator_traits<mocklist_iterator_type>::pointer l = &i;

        bool is_forward_iterator = std::is_same<
            std::iterator_traits<mocklist_iterator_type>::iterator_category,
            std::forward_iterator_tag>::value;

        REQUIRE(is_forward_iterator == true);
    }

    SECTION("dereference")
    {
        auto is_reference = std::is_same<decltype(*beg_it), int&>::value;

        REQUIRE(is_reference == true);
        REQUIRE(*beg_it == 1);
    }

    SECTION("preincrement")
    {
        auto ref_it = ++beg_it;

        bool is_iterator_reference =
            std::is_same<decltype(++beg_it), mocklist_iterator_type&>::value;

        REQUIRE(ref_it == beg_it);
        REQUIRE(*beg_it == 2);
        REQUIRE(is_iterator_reference == true);
    }

    SECTION("EqualityComparable")
    {
        bool equal = beg_it == end_it;

        REQUIRE(equal == false);
        REQUIRE(beg_it == mocklist.begin());
    }

    ////////////////////////////////////////////////////////////////////////////
    // InputIterator
    SECTION("!=")
    {
        bool not_equal = beg_it != mocklist.begin();

        REQUIRE(beg_it != end_it);
        REQUIRE(not_equal == false);
    }

    SECTION("postincrement")
    {
        bool is_conv_to_const_ref =
            std::is_convertible<decltype(beg_it++),
                                const mocklist_iterator_type&>::value;

        (void)beg_it++;

        REQUIRE(is_conv_to_const_ref == true);
        REQUIRE(*beg_it == 2);
    }

    SECTION("postincrement and dereference")
    {
        bool is_conv_to_value_type =
            std::is_convertible<decltype(*beg_it++), int>::value;

        auto val = *beg_it++;

        REQUIRE(is_conv_to_value_type == true);
        REQUIRE(val == 1);
        REQUIRE(*beg_it == 2);
    }

    ////////////////////////////////////////////////////////////////////////////
    // OutputIterator
    SECTION("assignment through iterator")
    {
        *beg_it = 10;

        REQUIRE(*beg_it == 10);
        REQUIRE(mocklist.front().i == 10);
        REQUIRE(mocklist.front().c == 'a');
    }

    ////////////////////////////////////////////////////////////////////////////
    // ForwardIterator
    SECTION("DefaultConstructible")
    {
        mocklist_iterator_type it;
        mocklist_iterator_type it2{};
        mocklist_iterator_type();
        mocklist_iterator_type{};
    }

    SECTION("multipass guarantee")
    {
        auto beg_it_copy = beg_it;
        ++beg_it;
        ++beg_it;

        auto val0 = *beg_it_copy++;
        auto val1 = *beg_it_copy++;
        auto val2 = *beg_it_copy;

        REQUIRE(val0 == 1);
        REQUIRE(val1 == 2);
        REQUIRE(val2 == 3);
    }

    ////////////////////////////////////////////////////////////////////////////
    // Test std algorithms
    SECTION("std::equal")
    {
        std::forward_list<mock> mocklist_copy = mocklist;

        mocklist_iterator_type beg_it_copy(mocklist_copy.begin());

        REQUIRE(std::equal(beg_it, end_it, beg_it_copy) == true);
    }
}
<commit_msg>Test using std::find. 	modified:   tests/test_member_iterator2.cpp<commit_after>#include "catch.hpp"

#include <utility>
#include <type_traits>
#include <iterator>
#include <algorithm>

#include <member_iterator.hpp>

#include <forward_list>

TEST_CASE("member_iterator based on ForwardIterator", "[member_iterator]")
{
    struct mock
    {
        char c;
        int i;
    };

    std::forward_list<mock> mocklist{{'a', 1}, {'b', 2}, {'c', 3}};

    typedef helene::
        member_iterator<int, mock, std::forward_list<mock>::iterator, &mock::i>
            mocklist_iterator_type;

    mocklist_iterator_type beg_it = mocklist.begin();
    mocklist_iterator_type end_it = mocklist.end();

    ////////////////////////////////////////////////////////////////////////////
    // Iterator concept
    SECTION("construction")
    {
        auto elem = *beg_it;
        mocklist_iterator_type cop_it = beg_it;
        mocklist_iterator_type mov_it = std::move(beg_it);

        REQUIRE(*mov_it == elem);
        REQUIRE(cop_it == mov_it);
    }

    SECTION("assignment")
    {
        mocklist_iterator_type cop_it = beg_it;
        cop_it = end_it;

        REQUIRE(cop_it == end_it);
    }

    SECTION("move assignment")
    {
        mocklist_iterator_type an_it = beg_it;
        mocklist_iterator_type another_it = end_it;

        another_it = std::move(an_it);

        REQUIRE(another_it == beg_it);
        REQUIRE(*another_it == *beg_it);
    }

    SECTION("swappable")
    {
        using std::swap;

        mocklist_iterator_type beg_it2 = beg_it;
        mocklist_iterator_type end_it2 = end_it;

        swap(beg_it2, end_it2);

        REQUIRE(beg_it2 == end_it);
        REQUIRE(end_it2 == beg_it);
    }

    SECTION("traits")
    {
        std::iterator_traits<mocklist_iterator_type>::value_type i = 20;
        std::iterator_traits<mocklist_iterator_type>::difference_type j = -2;
        std::iterator_traits<mocklist_iterator_type>::reference k = i;
        std::iterator_traits<mocklist_iterator_type>::pointer l = &i;

        bool is_forward_iterator = std::is_same<
            std::iterator_traits<mocklist_iterator_type>::iterator_category,
            std::forward_iterator_tag>::value;

        REQUIRE(is_forward_iterator == true);
    }

    SECTION("dereference")
    {
        auto is_reference = std::is_same<decltype(*beg_it), int&>::value;

        REQUIRE(is_reference == true);
        REQUIRE(*beg_it == 1);
    }

    SECTION("preincrement")
    {
        auto ref_it = ++beg_it;

        bool is_iterator_reference =
            std::is_same<decltype(++beg_it), mocklist_iterator_type&>::value;

        REQUIRE(ref_it == beg_it);
        REQUIRE(*beg_it == 2);
        REQUIRE(is_iterator_reference == true);
    }

    SECTION("EqualityComparable")
    {
        bool equal = beg_it == end_it;

        REQUIRE(equal == false);
        REQUIRE(beg_it == mocklist.begin());
    }

    ////////////////////////////////////////////////////////////////////////////
    // InputIterator
    SECTION("!=")
    {
        bool not_equal = beg_it != mocklist.begin();

        REQUIRE(beg_it != end_it);
        REQUIRE(not_equal == false);
    }

    SECTION("postincrement")
    {
        bool is_conv_to_const_ref =
            std::is_convertible<decltype(beg_it++),
                                const mocklist_iterator_type&>::value;

        (void)beg_it++;

        REQUIRE(is_conv_to_const_ref == true);
        REQUIRE(*beg_it == 2);
    }

    SECTION("postincrement and dereference")
    {
        bool is_conv_to_value_type =
            std::is_convertible<decltype(*beg_it++), int>::value;

        auto val = *beg_it++;

        REQUIRE(is_conv_to_value_type == true);
        REQUIRE(val == 1);
        REQUIRE(*beg_it == 2);
    }

    ////////////////////////////////////////////////////////////////////////////
    // OutputIterator
    SECTION("assignment through iterator")
    {
        *beg_it = 10;

        REQUIRE(*beg_it == 10);
        REQUIRE(mocklist.front().i == 10);
        REQUIRE(mocklist.front().c == 'a');
    }

    ////////////////////////////////////////////////////////////////////////////
    // ForwardIterator
    SECTION("DefaultConstructible")
    {
        mocklist_iterator_type it;
        mocklist_iterator_type it2{};
        mocklist_iterator_type();
        mocklist_iterator_type{};
    }

    SECTION("multipass guarantee")
    {
        auto beg_it_copy = beg_it;
        ++beg_it;
        ++beg_it;

        auto val0 = *beg_it_copy++;
        auto val1 = *beg_it_copy++;
        auto val2 = *beg_it_copy;

        REQUIRE(val0 == 1);
        REQUIRE(val1 == 2);
        REQUIRE(val2 == 3);
    }

    ////////////////////////////////////////////////////////////////////////////
    // Test std algorithms
    SECTION("std::equal")
    {
        std::forward_list<mock> mocklist_copy = mocklist;

        mocklist_iterator_type beg_it_copy(mocklist_copy.begin());

        REQUIRE(std::equal(beg_it, end_it, beg_it_copy) == true);
    }

    SECTION("std::find")
    {
        auto found = std::find(beg_it, end_it, 2);

        REQUIRE(found != end_it);
    }
}
<|endoftext|>


<commit_before>#include <gtest/gtest.h>

#include "uint256_t.h"

TEST(Constructor, standard){
    uint256_t value(0x0123456789abcdefULL);
    const uint256_t original = value;

    EXPECT_EQ(uint256_t(), 0);
    EXPECT_EQ(value, original);
    EXPECT_EQ(uint256_t(std::move(value)), original);
    EXPECT_EQ(value, 0x0123456789abcdefULL);
}

TEST(Constructor, one){
    EXPECT_EQ(uint256_t(true).upper(),  false);
    EXPECT_EQ(uint256_t(true).lower(),   true);
    EXPECT_EQ(uint256_t(false).upper(), false);
    EXPECT_EQ(uint256_t(false).lower(), false);

    EXPECT_EQ(uint256_t((uint8_t)  0x01ULL).upper(),               0ULL);
    EXPECT_EQ(uint256_t((uint16_t) 0x0123ULL).upper(),             0ULL);
    EXPECT_EQ(uint256_t((uint32_t) 0x01234567ULL).upper(),         0ULL);
    EXPECT_EQ(uint256_t((uint64_t) 0x0123456789abcdefULL).upper(), 0ULL);

    EXPECT_EQ(uint256_t((uint8_t)  0x01ULL).lower(),               (uint8_t)  0x01ULL);
    EXPECT_EQ(uint256_t((uint16_t) 0x0123ULL).lower(),             (uint16_t) 0x0123ULL);
    EXPECT_EQ(uint256_t((uint32_t) 0x01234567ULL).lower(),         (uint32_t) 0x01234567ULL);
    EXPECT_EQ(uint256_t((uint64_t) 0x0123456789abcdefULL).lower(), (uint64_t) 0x0123456789abcdefULL);
}

TEST(Constructor, two){
    for(uint8_t hi = 0; hi < 2; hi++){
        for(uint8_t lo = 0; lo < 2; lo++){
            const uint256_t val(hi, lo);
            EXPECT_EQ(val.upper(), hi);
            EXPECT_EQ(val.lower(), lo);
        }
    }

    EXPECT_EQ(uint256_t((uint8_t)  0x01ULL,               (uint8_t)  0x01ULL).upper(),               (uint8_t)  0x01ULL);
    EXPECT_EQ(uint256_t((uint16_t) 0x0123ULL,             (uint16_t) 0x0123ULL).upper(),             (uint16_t) 0x0123ULL);
    EXPECT_EQ(uint256_t((uint32_t) 0x01234567ULL,         (uint32_t) 0x01234567ULL).upper(),         (uint32_t) 0x01234567ULL);
    EXPECT_EQ(uint256_t((uint64_t) 0x0123456789abcdefULL, (uint64_t) 0x0123456789abcdefULL).upper(), (uint64_t) 0x0123456789abcdefULL);

    EXPECT_EQ(uint256_t((uint8_t)  0x01ULL,               (uint8_t)  0x01ULL).lower(),               (uint8_t)  0x01ULL);
    EXPECT_EQ(uint256_t((uint16_t) 0x0123ULL,             (uint16_t) 0x0123ULL).lower(),             (uint16_t) 0x0123ULL);
    EXPECT_EQ(uint256_t((uint32_t) 0x01234567ULL,         (uint32_t) 0x01234567ULL).lower(),         (uint32_t) 0x01234567ULL);
    EXPECT_EQ(uint256_t((uint64_t) 0x0123456789abcdefULL, (uint64_t) 0x0123456789abcdefULL).lower(), (uint64_t) 0x0123456789abcdefULL);
}

TEST(Constructor, four){
    for(uint8_t hi_hi = 0; hi_hi < 2; hi_hi++){
        for(uint8_t hi_lo = 0; hi_lo < 2; hi_lo++){
            for(uint8_t lo_hi = 0; lo_hi < 2; lo_hi++){
                for(uint8_t lo_lo = 0; lo_lo < 2; lo_lo++){
                    const uint256_t val(hi_hi, hi_lo, lo_hi, lo_lo);
                    EXPECT_EQ(val.upper().upper(), hi_hi);
                    EXPECT_EQ(val.upper().lower(), hi_lo);
                    EXPECT_EQ(val.lower().upper(), lo_hi);
                    EXPECT_EQ(val.lower().lower(), lo_lo);
                }
            }
        }
    }
}
<commit_msg>Added string constructor test<commit_after>#include <gtest/gtest.h>

#include "uint256_t.h"

TEST(Constructor, standard){
    uint256_t value(0x0123456789abcdefULL);
    const uint256_t original = value;

    EXPECT_EQ(uint256_t(), 0);
    EXPECT_EQ(value, original);
    EXPECT_EQ(uint256_t(std::move(value)), original);
    EXPECT_EQ(value, 0x0123456789abcdefULL);
}

TEST(Constructor, string){
    EXPECT_EQ(uint256_t("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), uint256_max);
    EXPECT_EQ(uint256_t("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), uint256_max);
    EXPECT_EQ(uint256_t("0"), 0);
    EXPECT_EQ(uint256_t("0"), 0);
    EXPECT_EQ(uint256_t("0x0123456789abcdef"), 0x0123456789abcdefULL);
}

TEST(Constructor, one){
    EXPECT_EQ(uint256_t(true).upper(),  false);
    EXPECT_EQ(uint256_t(true).lower(),   true);
    EXPECT_EQ(uint256_t(false).upper(), false);
    EXPECT_EQ(uint256_t(false).lower(), false);

    EXPECT_EQ(uint256_t((uint8_t)  0x01ULL).upper(),               0ULL);
    EXPECT_EQ(uint256_t((uint16_t) 0x0123ULL).upper(),             0ULL);
    EXPECT_EQ(uint256_t((uint32_t) 0x01234567ULL).upper(),         0ULL);
    EXPECT_EQ(uint256_t((uint64_t) 0x0123456789abcdefULL).upper(), 0ULL);

    EXPECT_EQ(uint256_t((uint8_t)  0x01ULL).lower(),               (uint8_t)  0x01ULL);
    EXPECT_EQ(uint256_t((uint16_t) 0x0123ULL).lower(),             (uint16_t) 0x0123ULL);
    EXPECT_EQ(uint256_t((uint32_t) 0x01234567ULL).lower(),         (uint32_t) 0x01234567ULL);
    EXPECT_EQ(uint256_t((uint64_t) 0x0123456789abcdefULL).lower(), (uint64_t) 0x0123456789abcdefULL);
}

TEST(Constructor, two){
    for(uint8_t hi = 0; hi < 2; hi++){
        for(uint8_t lo = 0; lo < 2; lo++){
            const uint256_t val(hi, lo);
            EXPECT_EQ(val.upper(), hi);
            EXPECT_EQ(val.lower(), lo);
        }
    }

    EXPECT_EQ(uint256_t((uint8_t)  0x01ULL,               (uint8_t)  0x01ULL).upper(),               (uint8_t)  0x01ULL);
    EXPECT_EQ(uint256_t((uint16_t) 0x0123ULL,             (uint16_t) 0x0123ULL).upper(),             (uint16_t) 0x0123ULL);
    EXPECT_EQ(uint256_t((uint32_t) 0x01234567ULL,         (uint32_t) 0x01234567ULL).upper(),         (uint32_t) 0x01234567ULL);
    EXPECT_EQ(uint256_t((uint64_t) 0x0123456789abcdefULL, (uint64_t) 0x0123456789abcdefULL).upper(), (uint64_t) 0x0123456789abcdefULL);

    EXPECT_EQ(uint256_t((uint8_t)  0x01ULL,               (uint8_t)  0x01ULL).lower(),               (uint8_t)  0x01ULL);
    EXPECT_EQ(uint256_t((uint16_t) 0x0123ULL,             (uint16_t) 0x0123ULL).lower(),             (uint16_t) 0x0123ULL);
    EXPECT_EQ(uint256_t((uint32_t) 0x01234567ULL,         (uint32_t) 0x01234567ULL).lower(),         (uint32_t) 0x01234567ULL);
    EXPECT_EQ(uint256_t((uint64_t) 0x0123456789abcdefULL, (uint64_t) 0x0123456789abcdefULL).lower(), (uint64_t) 0x0123456789abcdefULL);
}

TEST(Constructor, four){
    for(uint8_t hi_hi = 0; hi_hi < 2; hi_hi++){
        for(uint8_t hi_lo = 0; hi_lo < 2; hi_lo++){
            for(uint8_t lo_hi = 0; lo_hi < 2; lo_hi++){
                for(uint8_t lo_lo = 0; lo_lo < 2; lo_lo++){
                    const uint256_t val(hi_hi, hi_lo, lo_hi, lo_lo);
                    EXPECT_EQ(val.upper().upper(), hi_hi);
                    EXPECT_EQ(val.upper().lower(), hi_lo);
                    EXPECT_EQ(val.lower().upper(), lo_hi);
                    EXPECT_EQ(val.lower().lower(), lo_lo);
                }
            }
        }
    }
}
<|endoftext|>