1 //===-- Loader test to check args to main ---------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 #include "src/assert/assert.h"
12 static bool my_streq(const char *lhs
, const char *rhs
) {
14 for (l
= lhs
, r
= rhs
; *l
!= '\0' && *r
!= '\0'; ++l
, ++r
)
18 return *l
== '\0' && *r
== '\0';
21 int main(int argc
, char **argv
, char **envp
) {
22 assert(argc
== 4 && "Unexpected argc.");
23 assert(my_streq(argv
[1], "1") && "Unexpected argv[1].");
24 assert(my_streq(argv
[2], "2") && "Unexpected argv[2].");
25 assert(my_streq(argv
[3], "3") && "Unexpected argv[3].");
27 bool found_france
= false;
28 bool found_germany
= false;
29 for (; *envp
!= nullptr; ++envp
) {
30 if (my_streq(*envp
, "FRANCE=Paris"))
32 if (my_streq(*envp
, "GERMANY=Berlin"))
36 assert(found_france
&& found_germany
&&
37 "Did not find whats expected in envp.");