mfbt/tests/TestMacroArgs.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mfbt/tests/TestMacroArgs.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,26 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set ts=8 sts=2 et sw=2 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#include "mozilla/MacroArgs.h"
    1.11 +
    1.12 +static_assert(MOZ_PASTE_PREFIX_AND_ARG_COUNT(100, a, b, c) == 1003, "");
    1.13 +
    1.14 +static_assert(MOZ_PASTE_PREFIX_AND_ARG_COUNT(, a, b, c) == 3, "");
    1.15 +static_assert(MOZ_PASTE_PREFIX_AND_ARG_COUNT(, a) == 1, "");
    1.16 +static_assert(MOZ_PASTE_PREFIX_AND_ARG_COUNT(, !a) == 1, "");
    1.17 +static_assert(MOZ_PASTE_PREFIX_AND_ARG_COUNT(, (a, b)) == 1, "");
    1.18 +
    1.19 +static_assert(MOZ_PASTE_PREFIX_AND_ARG_COUNT(, MOZ_ARGS_AFTER_1(a, b, c)) == 2,
    1.20 +              "MOZ_ARGS_AFTER_1(a, b, c) should expand to 'b, c'");
    1.21 +static_assert(MOZ_ARGS_AFTER_2(a, b, 3) == 3,
    1.22 +              "MOZ_ARGS_AFTER_2(a, b, 3) should expand to '3'");
    1.23 +
    1.24 +static_assert(MOZ_ARG_1(10, 20, 30) == 10, "");
    1.25 +static_assert(MOZ_ARG_2(10, 20, 30) == 20, "");
    1.26 +
    1.27 +int main()
    1.28 +{
    1.29 +}

mercurial