Skip to content

Commit

Permalink
add test for interop with abseil
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed Feb 18, 2023
1 parent 329c8ab commit 8d0b736
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
6 changes: 6 additions & 0 deletions recipe/cmake_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
project(cf_dummy LANGUAGES CXX)
cmake_minimum_required(VERSION 3.12)
find_package(absl REQUIRED CONFIG)

add_executable(re2_example re2_example.cpp)
target_link_libraries(re2_example absl::flags absl::strings)
16 changes: 16 additions & 0 deletions recipe/cmake_test/re2_example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// try that conversion from absl::string_view to re2::StringPiece works

#include "absl/strings/string_view.h"
#include "re2/stringpiece.h"

absl::string_view some_function(absl::string_view text) {
return text;
}

int main() {
re2::StringPiece sp = "hello, world";
// should be transformable between types by compiler
some_function(sp)

return 0;
}
15 changes: 15 additions & 0 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ requirements:
run:

test:
requires:
- {{ compiler('cxx') }}
- cmake
- libabseil
- ninja
files:
- cmake_test/
commands:
- test -f ${PREFIX}/lib/libre2.so # [linux]
- test -f ${PREFIX}/lib/libre2.dylib # [osx]
Expand All @@ -41,6 +48,14 @@ test:
- if exist %PREFIX%\\Library\\lib\\re2_static.lib exit 1 # [win]
- if not exist %PREFIX%\\Library\\bin\\re2.dll exit 1 # [win]

# CMake integration
- cd cmake_test
- cmake $CMAKE_ARGS -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 . # [unix]
- cmake %CMAKE_ARGS% -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 . # [win]
- cmake --build .
- ./re2_example # [unix]
- re2_example.exe # [win]

about:
home: https://github.com/google/re2/
license: BSD-3-Clause
Expand Down

0 comments on commit 8d0b736

Please sign in to comment.