From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 68137 invoked by alias); 27 Oct 2015 19:48:06 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 68121 invoked by uid 89); 27 Oct 2015 19:48:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 27 Oct 2015 19:48:03 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zr9yC-0002tW-5P for gcc-patches@gcc.gnu.org; Tue, 27 Oct 2015 15:31:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42554) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zr9yB-0002t4-VV for gcc-patches@gcc.gnu.org; Tue, 27 Oct 2015 15:31:44 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id B42A7C0B590E for ; Tue, 27 Oct 2015 19:31:43 +0000 (UTC) Received: from c64.redhat.com (vpn-230-173.phx2.redhat.com [10.3.230.173]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9RJVW5o018778; Tue, 27 Oct 2015 15:31:43 -0400 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH 14/16] Add test-tree.c to unittests Date: Tue, 27 Oct 2015 19:48:00 -0000 Message-Id: <1445975355-37660-15-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1445975355-37660-1-git-send-email-dmalcolm@redhat.com> References: <5589B2FB.8010500@redhat.com> <1445975355-37660-1-git-send-email-dmalcolm@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 X-IsSubscribed: yes X-SW-Source: 2015-10/txt/msg02960.txt.bz2 gcc/testsuite/ChangeLog: * unittests/test-tree.c: New file. --- gcc/testsuite/unittests/test-tree.c | 101 ++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 gcc/testsuite/unittests/test-tree.c diff --git a/gcc/testsuite/unittests/test-tree.c b/gcc/testsuite/unittests/test-tree.c new file mode 100644 index 0000000..39754af --- /dev/null +++ b/gcc/testsuite/unittests/test-tree.c @@ -0,0 +1,101 @@ +/* Unit tests for GCC's tree types. + Copyright (C) 2015 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#include "config.h" +#include "gtest/gtest.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "opts.h" +#include "signop.h" +#include "hash-set.h" +#include "fixed-value.h" +#include "alias.h" +#include "flags.h" +#include "symtab.h" +#include "tree-core.h" +#include "stor-layout.h" +#include "tree.h" +#include "stringpool.h" +#include "stor-layout.h" +#include "rtl.h" +#include "predict.h" +#include "vec.h" +#include "hashtab.h" +#include "hash-set.h" +#include "machmode.h" +#include "hard-reg-set.h" +#include "input.h" +#include "function.h" +#include "dominance.h" +#include "cfg.h" +#include "cfganal.h" +#include "basic-block.h" +#include "tree-ssa-alias.h" +#include "internal-fn.h" +#include "gimple-fold.h" +#include "gimple-expr.h" +#include "toplev.h" +#include "print-tree.h" +#include "tree-iterator.h" +#include "gimplify.h" +#include "tree-cfg.h" +#include "fold-const.h" + +namespace { + +/* Verify that integer constants are sane. */ + +TEST (tree_test, integer_constants) +{ + ASSERT_TRUE (integer_type_node != NULL); + EXPECT_TRUE (build_int_cst (integer_type_node, 0) != NULL); + + tree type = integer_type_node; + + tree zero = build_zero_cst (type); + EXPECT_EQ (INTEGER_CST, TREE_CODE (zero)); + EXPECT_EQ (type, TREE_TYPE (zero)); + + tree one = build_int_cst (type, 1); + EXPECT_EQ (INTEGER_CST, TREE_CODE (one)); + EXPECT_EQ (type, TREE_TYPE (zero)); +} + +/* Verify identifiers. */ + +TEST (tree_test, identifiers) +{ + tree identifier = get_identifier ("foo"); + EXPECT_EQ (3, IDENTIFIER_LENGTH (identifier)); + EXPECT_STREQ ("foo", IDENTIFIER_POINTER (identifier)); +} + +/* Verify LABEL_DECL. */ + +TEST (tree_test, labels) +{ + tree identifier = get_identifier ("err"); + tree label_decl = build_decl (UNKNOWN_LOCATION, LABEL_DECL, + identifier, void_type_node); + EXPECT_EQ (-1, LABEL_DECL_UID (label_decl)); + EXPECT_FALSE (FORCED_LABEL (label_decl)); +} + +} // anon namespace -- 1.8.5.3