From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id B3AB256D041; Tue, 31 Oct 2023 21:12:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B3AB256D041 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1698775945; bh=HpVNzGYOR20QLhwBTDCtyvuLaxmas3OqUnQVnsfl6k0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=cH8mh9JuFUmLNZzcUN7mRF9IqYDh+G28xr2ITgk4cvM8kRDE3oX7zg0ccUNIpbcOc v+UFs0ib1uIqzlsqxqSnrpNFMQoqd9o5Xt4UYbun/5eQ2jaE87Rnv8kAc3nJdo75ht FYndb7AKYnITLTCkAYkQPF9wRSfIQj4v9kll4/q8= Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 1932356D041 for ; Tue, 31 Oct 2023 21:12:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1932356D041 Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-507cd62472dso106666e87.0 for ; Tue, 31 Oct 2023 11:12:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698775943; x=1699380743; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0Khc/3a5G17nJ5XYALLjy9k3iiRzMdZ7sahnAYgj12E=; b=v+pKLlw9vybeI5ecHOAtfVMd/wJ25eQvemdIxro85tLjRjCT9Hhq7uEdxFWKrog2YN ATReBQV8JgkLHDDZMXoQ+I5Flm7VvgCWmEvuy5ujes+aNwm9bjHG0iZIGdlsUxZcJfjC PYZVdYFxCE/PdUUYGcXPYWQBOfx6egArTe6sW5L1FMBJREiB0F5FFQS1AiVjrRY8HBt2 SDxYp505HP5TLvGUpAUWW/ynnYYipITyBLuYE/XmPgAg9UhknJ64wszWzu3AF+RIKe9K 6xnI+EdjyiVEF3pqaejhUNkRuXlskAormhiq0futDFXnP6hrug419Kx5AoznoMPBbubK stHQ== X-Gm-Message-State: AOJu0YxOtGGBzkuQ/FuE+lNsbRbkZgIeel+d+3B7QJFaG4n8PhtIYN4B b5Khzt1u5Fj5ht+e396yE4Y+8GxzylUw6Q== X-Google-Smtp-Source: AGHT+IFSH7p83samxsW1X+fKQNji20mhXo1HN2nystrMUUUvHlGfhIhHK9SUOvTSDZ2PoL2Wf+nE0Q== X-Received: by 2002:a05:6512:1046:b0:500:a1e4:fc45 with SMTP id c6-20020a056512104600b00500a1e4fc45mr109254lfb.21.1698775942776; Tue, 31 Oct 2023 11:12:22 -0700 (PDT) Received: from pony.bronevichok.ru ([79.164.223.111]) by smtp.gmail.com with ESMTPSA id p12-20020a2ea4cc000000b002bce38190a3sm249318ljm.34.2023.10.31.11.12.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 11:12:22 -0700 (PDT) To: tarantool-patches@dev.tarantool.org, Sergey Kaplun , max.kokryashkin@gmail.com Date: Tue, 31 Oct 2023 21:11:43 +0300 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: <26636e3dcb8ade3bdc23d9544f9a7e2ffe4322b2.1695711374.git.sergeyb@tarantool.org> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit 1/2] test: introduce asserts assert_str{_not}_equal X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" From: Sergey Bronnikov The patch follows up commit a0483bd214f2 ("test: introduce module for C tests") and adds additional asserts suitable for comparing strings. --- test/tarantool-c-tests/README.md | 2 ++ test/tarantool-c-tests/test.h | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/test/tarantool-c-tests/README.md b/test/tarantool-c-tests/README.md index 462534be..8fad6407 100644 --- a/test/tarantool-c-tests/README.md +++ b/test/tarantool-c-tests/README.md @@ -35,6 +35,8 @@ glibc `assert()`: equal to the `b`. * `assert_double{_not}_equal(a, b)` -- check that two doubles are {not} **exactly** equal. +* `assert_str{_not}_equal(a, b)` -- check that `char *` variable `a` is {not} + equal to the `b`. ## Directives diff --git a/test/tarantool-c-tests/test.h b/test/tarantool-c-tests/test.h index 8b14c705..bbf573b2 100644 --- a/test/tarantool-c-tests/test.h +++ b/test/tarantool-c-tests/test.h @@ -13,8 +13,6 @@ * * Helpers assert macros: * - assert_uint_equal if needed * - assert_uint_not_equal if needed - * - assert_str_equal if needed - * - assert_str_not_equal if needed * - assert_memory_equal if needed * - assert_memory_not_equal if needed * * Pragmas. @@ -214,4 +212,19 @@ static inline int todo(const char *reason) ); \ } while (0) +#define assert_str_equal(got, expected, n) do { \ + assert_general(strncmp(got, expected, n) == 0, \ + ASSERT_EQUAL_FMT(int, "%d"), \ + __FILE__, __LINE__, (got), (expected) \ + ); \ +} while (0) + +#define assert_str_not_equal(got, unexpected, n) do { \ + assert_general(strncmp(got, expected, n) != 0, \ + ASSERT_NOT_EQUAL_FMT(int, "%d"), \ + __FILE__, __LINE__, (got), (unexpected) \ + ); \ +} while (0) + + #endif /* TARANTOOL_LUAJIT_TEST_H */ -- 2.34.1