forked from enlightenment/efl
csharp: Fix helper function
Summary: Was failing if the suffix were equal to the source string Reviewers: felipealmeida, segfaultxavi, YOhoho, brunobelo Reviewed By: brunobelo Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10708
This commit is contained in:
parent
b22594a10b
commit
642b243df9
|
@ -16,6 +16,8 @@
|
|||
#ifndef EOLIAN_MONO_GENERATION_CONTEXTS_HH
|
||||
#define EOLIAN_MONO_GENERATION_CONTEXTS_HH
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "grammar/context.hpp"
|
||||
#include "grammar/indentation.hpp"
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "utils.hh"
|
||||
|
||||
#include "grammar/integral.hpp"
|
||||
|
|
|
@ -98,7 +98,7 @@ namespace eolian_mono { namespace utils {
|
|||
|
||||
inline bool ends_with(std::string const& source, std::string suffix)
|
||||
{
|
||||
if (source.size() > suffix.size())
|
||||
if (source.size() >= suffix.size())
|
||||
return (0 == source.compare(source.size() - suffix.size(), suffix.size(), suffix));
|
||||
else
|
||||
return false;
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
#include "grammar/generator.hpp"
|
||||
#include "grammar/attributes.hpp"
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#ifndef EOLIAN_CXX_TYPE_TRAITS_HH
|
||||
#define EOLIAN_CXX_TYPE_TRAITS_HH
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace efl { namespace eolian { namespace grammar { namespace type_traits {
|
||||
|
||||
template <typename G>
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright 2019 by its authors. See AUTHORS.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "../../bin/eolian_mono/eolian/mono/utils.hh"
|
||||
|
||||
#include <check.h>
|
||||
#include "../efl_check.h"
|
||||
|
||||
|
||||
|
||||
EFL_START_TEST(eolian_mono_test_util_ends_with)
|
||||
{
|
||||
ck_assert(eolian_mono::utils::ends_with("SomeFlags", "Flags"));
|
||||
ck_assert(eolian_mono::utils::ends_with("Flags", "Flags"));
|
||||
ck_assert(!eolian_mono::utils::ends_with("Flagz", "Flags"));
|
||||
ck_assert(!eolian_mono::utils::ends_with("FlagsSome", "Flags"));
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
void
|
||||
eolian_mono_utils_test(TCase* tc)
|
||||
{
|
||||
tcase_add_test(tc, eolian_mono_test_util_ends_with);
|
||||
}
|
||||
|
||||
static const Efl_Test_Case etc[] = {
|
||||
{ "Eolian mono utils", eolian_mono_utils_test },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int failed_count;
|
||||
|
||||
if (!_efl_test_option_disp(argc, argv, etc))
|
||||
return 0;
|
||||
|
||||
putenv(const_cast<char*>("EFL_RUN_IN_TREE=1"));
|
||||
|
||||
failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
|
||||
"Eolian C++", etc, NULL, NULL);
|
||||
|
||||
return (failed_count == 0) ? 0 : 255;
|
||||
}
|
|
@ -174,3 +174,14 @@ else
|
|||
env : env_mono
|
||||
)
|
||||
endif
|
||||
|
||||
eolian_mono_helpers_suite = executable('eolian-mono-suite',
|
||||
['eolian_mono_suite.cc'],
|
||||
include_directories : config_dir,
|
||||
dependencies: [check, eolian_cxx, eina_cxx],
|
||||
cpp_args : package_c_args + [
|
||||
'-DTESTS_BUILD_DIR="'+meson.current_build_dir()+'"',
|
||||
'-DTESTS_SRC_DIR="'+meson.current_source_dir()+'"']
|
||||
)
|
||||
|
||||
test('eolian-mono-suite', eolian_mono_helpers_suite)
|
||||
|
|
Loading…
Reference in New Issue