/* * Copyright (c) 2014 Eran Pe'er. * * This program is made available under the terms of the MIT License. * * Created on Mar 10, 2014 */ #pragma once #include #include namespace fakeit { struct Quantity { Quantity(const int quantity) : quantity(quantity) { } const int quantity; } static Once(1); template struct Quantifier : public Quantity { Quantifier(const int quantity, const R &value) : Quantity(quantity), value(value) { } const R &value; }; template<> struct Quantifier : public Quantity { explicit Quantifier(const int quantity) : Quantity(quantity) { } }; struct QuantifierFunctor : public Quantifier { QuantifierFunctor(const int quantity) : Quantifier(quantity) { } template Quantifier operator()(const R &value) { return Quantifier(quantity, value); } }; template struct Times : public Quantity { Times() : Quantity(q) { } template static Quantifier of(const R &value) { return Quantifier(q, value); } static Quantifier Void() { return Quantifier(q); } }; #if defined (__GNUG__) || (_MSC_VER >= 1900) inline QuantifierFunctor operator "" _Times(unsigned long long n) { return QuantifierFunctor((int) n); } inline QuantifierFunctor operator "" _Time(unsigned long long n) { if (n != 1) throw std::invalid_argument("Only 1_Time is supported. Use X_Times (with s) if X is bigger than 1"); return QuantifierFunctor((int) n); } #endif }