Browse Source

add .clang-format / reformat

If you dont like reformatting
of complete codebases, the solution is to USE this.
master
heck 5 months ago
parent
commit
eaa77767a7
17 changed files with 825 additions and 727 deletions
  1. +45
    -0
      .clang-format
  2. +11
    -12
      src/bloblist.cc
  3. +69
    -45
      src/bloblist.hh
  4. +17
    -19
      src/crlf.cc
  5. +1
    -2
      src/crlf.hh
  6. +23
    -25
      src/identity.cc
  7. +19
    -23
      src/stringlist.cc
  8. +42
    -45
      src/types.cc
  9. +6
    -8
      src/types.hh
  10. +221
    -183
      src/wrapper.hh
  11. +19
    -13
      test/unittest_identity.cc
  12. +119
    -120
      test/unittest_message.cc
  13. +73
    -61
      test/unittest_nfc.cc
  14. +51
    -55
      test/unittest_nfc16.cc
  15. +49
    -52
      test/unittest_nfcstring.cc
  16. +31
    -33
      test/unittest_stringlist.cc
  17. +29
    -31
      test/unittest_stringpair.cc

+ 45
- 0
.clang-format View File

@ -0,0 +1,45 @@
BasedOnStyle: LLVM
Language: Cpp
Standard: c++17
DerivePointerAlignment: true
SortIncludes: Never
ReflowComments: false
PointerAlignment: Left
AlignAfterOpenBracket: AlwaysBreak
AlignOperands: AlignAfterOperator
BreakConstructorInitializers: AfterColon
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
ExperimentalAutoDetectBinPacking: true
BreakBeforeBraces: Custom
BraceWrapping:
AfterFunction: true
ColumnLimit: 100
AllowAllConstructorInitializersOnNextLine: false
#BreakConstructorInitializersBeforeComma: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
PenaltyBreakBeforeFirstCallParameter: 0
PenaltyReturnTypeOnItsOwnLine: 1000000
PenaltyBreakAssignment: 1000000
PenaltyExcessCharacter: 10
IndentCaseLabels: true
IndentWidth: 4
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
SpaceAfterTemplateKeyword: false
AccessModifierOffset: -4
AllowShortBlocksOnASingleLine: Always
IndentPPDirectives: BeforeHash
IndentExternBlock: Indent
Cpp11BracedListStyle: false
BreakStringLiterals: false

+ 11
- 12
src/bloblist.cc View File

@ -2,44 +2,43 @@
#include <pEp/bloblist.h>
namespace pEp
{
namespace pEp {
template<>
void Wrapper<::bloblist_t*>::_free(::bloblist_t* bl)
{
::free_bloblist(bl);
}
// template<>
// template<>
int BlobList::size() const
{
return bloblist_length(value);
}
// faster than .size()==0 because it's not necessary to iterate throgh the whole list
// template<>
// template<>
bool BlobList::empty() const
{
return !(value && value->value);
}
// template<>
// template<>
void BlobList::clear()
{
free_bloblist(value);
value = nullptr;
}
// template<>
// template<>
void BlobList::push_back(Blob&& s)
{
// TODO
}
////////////////
////////////////
// no explicit instantiation noecessary, because of fully specialized class template. Okay. :-D
// template class ListWrapper<::bloblist_t*, void>;
// no explicit instantiation noecessary, because of fully specialized class template. Okay. :-D
// template class ListWrapper<::bloblist_t*, void>;
} // end of namespace pEp

+ 69
- 45
src/bloblist.hh View File

@ -7,55 +7,79 @@
#include "wrapper.hh"
#include <pEp/bloblist.h>
namespace pEp
{
namespace pEp {
template<>
class ListWrapper<::bloblist_t*, void> : public Wrapper<::bloblist_t*>
{
public:
typedef ::bloblist_t Blob;
typedef Wrapper<Blob*> Base;
typedef ListWrapper<Blob*, void> LW;
// does not own the *value
class iterator
{
template<>
class ListWrapper<::bloblist_t*, void> : public Wrapper<::bloblist_t*> {
public:
iterator() = default;
iterator operator++() { return (value ? value = value->next : value); }
Blob& operator*() { return *value; }
Blob* operator->() { return value; }
const Blob& operator*() const { return *value; }
const Blob* operator->() const { return value; }
bool operator==(const iterator& other) const { return value == other.value; }
bool operator!=(const iterator& other) const { return value != other.value; }
private:
iterator(::bloblist_t* _t) : value{_t} {}
::bloblist_t* value = nullptr;
friend class ListWrapper<::bloblist_t*, void>;
typedef ::bloblist_t Blob;
typedef Wrapper<Blob*> Base;
typedef ListWrapper<Blob*, void> LW;
// does not own the *value
class iterator {
public:
iterator() = default;
iterator operator++()
{
return (value ? value = value->next : value);
}
Blob& operator*()
{
return *value;
}
Blob* operator->()
{
return value;
}
const Blob& operator*() const
{
return *value;
}
const Blob* operator->() const
{
return value;
}
bool operator==(const iterator& other) const
{
return value == other.value;
}
bool operator!=(const iterator& other) const
{
return value != other.value;
}
private:
iterator(::bloblist_t* _t) : value{ _t } {}
::bloblist_t* value = nullptr;
friend class ListWrapper<::bloblist_t*, void>;
};
using Base::value;
ListWrapper() : Base() {}
iterator begin()
{
return iterator{ value };
}
iterator end() const
{
return iterator{};
}
int size() const;
bool empty() const;
void clear();
void push_back(Blob&&);
void emplace_back(char* data, size_t size, const char* mime_type, const char* filename);
};
using Base::value;
ListWrapper() : Base() {}
iterator begin() { return iterator{value}; }
iterator end() const { return iterator{}; }
int size() const;
bool empty() const;
void clear();
void push_back(Blob&&);
void emplace_back(char* data, size_t size, const char* mime_type, const char* filename);
};
using BlobList = ListWrapper<::bloblist_t*, void>;
using BlobList = ListWrapper<::bloblist_t*, void>;
} // end of namespace pEp


+ 17
- 19
src/crlf.cc View File

@ -1,26 +1,24 @@
#include "crlf.hh"
namespace pEp
{
namespace pEp {
std::string operator""_CRLF(const char* str, size_t length)
{
static const std::string CRLF{"\r\n"};
std::string ret;
ret.reserve(length + ((length+29)/30) + 2 ); // rough guess for average line length of 30.
const char* end = str + length;
// N.B.: Loop could be more optimized, but not necessary because it is only used for string literals.
for(; str != end; ++str)
std::string operator""_CRLF(const char* str, size_t length)
{
if(*str == '\n')
ret += CRLF;
else
ret += *str;
static const std::string CRLF{ "\r\n" };
std::string ret;
ret.reserve(length + ((length + 29) / 30) + 2); // rough guess for average line length of 30.
const char* end = str + length;
// N.B.: Loop could be more optimized, but not necessary because it is only used for string literals.
for (; str != end; ++str) {
if (*str == '\n')
ret += CRLF;
else
ret += *str;
}
return ret;
}
return ret;
}
} // end of namespace pEp

+ 1
- 2
src/crlf.hh View File

@ -6,8 +6,7 @@
#include <string>
namespace pEp
{
namespace pEp {
// creates a string where \n ("linefeed" a.k.a. LF) are replaced
// by \r\n ("carriage return + linefeed" a.k.a. CRLF).
// Useful to define strings in NET-ASCII or Net-Unicode (RFC5198) format


+ 23
- 25
src/identity.cc View File

@ -4,15 +4,14 @@
#include <string>
namespace pEp
{
namespace pEp {
template<>
template<>
::pEp_identity* Wrapper<::pEp_identity*>::_new<const char*, const char*, const char*, const char*>
(
const char *address, const char *fpr, const char *user_id,
const char *username
)
::pEp_identity* Wrapper<::pEp_identity*>::_new<const char*, const char*, const char*, const char*>(
const char* address,
const char* fpr,
const char* user_id,
const char* username)
{
return ::new_identity(address, fpr, user_id, username);
}
@ -22,14 +21,14 @@ namespace pEp
{
::free_identity(id);
}
template<>
::pEp_identity* Wrapper<::pEp_identity*>::copy_out() const
{
return identity_dup(value);
}
//////////////
//////////////
template<>
void Wrapper<::identity_list*>::_free(::identity_list* sl)
@ -44,8 +43,8 @@ namespace pEp
}
template<>
::pEp_identity* identity_list::* const ListWrapper<::identity_list*, ::pEp_identity*>::Value
= &identity_list::ident;
::pEp_identity* identity_list::*const
ListWrapper<::identity_list*, ::pEp_identity*>::Value = &identity_list::ident;
template<>
int IdentityList::size() const
@ -59,41 +58,40 @@ namespace pEp
{
return !(value && value->ident);
}
template<>
void IdentityList::clear()
{
free_identity_list(value);
value = nullptr;
}
template<>
void IdentityList::push_back(pEp_identity*&& id)
{
auto last = identity_list_add(value, id);
if(value==nullptr)
if (value == nullptr)
value = last;
}
template<>
ListWrapper<::identity_list*, pEp_identity*>::ListWrapper(const std::initializer_list<Wrapper<pEp_identity*>>& il)
: Base{}
ListWrapper<::identity_list*, pEp_identity*>::ListWrapper(
const std::initializer_list<Wrapper<pEp_identity*>>& il) :
Base{}
{
::identity_list* last = nullptr;
for(const Wrapper<pEp_identity*>& id : il)
{
::identity_list* last = nullptr;
for (const Wrapper<pEp_identity*>& id : il) {
last = identity_list_add(last, identity_dup(id.get()));
if(last==nullptr)
{
if (last == nullptr) {
throw std::runtime_error("Cannot create StringPairList from {}: Out Of Memory.");
}
if(value==nullptr)
if (value == nullptr)
value = last; // save the head of linked list.
}
}
////////////////
////////////////
template class ListWrapper<::identity_list*, ::pEp_identity*>;


+ 19
- 23
src/stringlist.cc View File

@ -5,17 +5,16 @@
#include <string>
namespace pEp
{
namespace pEp {
template<>
void Wrapper<::stringlist_t*>::_free(::stringlist_t* sl)
{
::free_stringlist(sl);
}
template<>
const char* stringlist_t::* const ListWrapper<stringlist_t*, const char*>::Value
= const_cast<const char* stringlist_t::*>(&stringlist_t::value);
const char* stringlist_t::*const ListWrapper<stringlist_t*, const char*>::Value =
const_cast<const char * stringlist_t::*>(&stringlist_t::value);
template<>
int StringList::size() const
@ -29,50 +28,47 @@ namespace pEp
{
return !(value && value->value);
}
template<>
void StringList::erase( const StringList::iterator& it)
void StringList::erase(const StringList::iterator& it)
{
if(it.value && it.value->value)
{
if (it.value && it.value->value) {
value = stringlist_delete(value, it.value->value);
}
}
template<>
void StringList::clear()
{
free_stringlist(value);
value = nullptr;
}
template<>
void StringList::push_back(const char*&& s)
{
auto last = stringlist_add(value, s);
if(value==nullptr)
if (value == nullptr)
value = last;
}
template<>
ListWrapper<::stringlist_t*, const char*>::ListWrapper(const std::initializer_list<const char*>& il)
: StringList{}
ListWrapper<::stringlist_t*, const char*>::ListWrapper(const std::initializer_list<const char*>& il) :
StringList{}
{
::stringlist_t* last = nullptr;
for(const char* s : il)
{
::stringlist_t* last = nullptr;
for (const char* s : il) {
last = stringlist_add(last, s);
if(last==nullptr)
{
if (last == nullptr) {
throw std::runtime_error("Cannot create StringPairList from {}: Out Of Memory.");
}
if(value==nullptr)
if (value == nullptr)
value = last; // save the head of linked list.
}
}
////////////////
////////////////
template class ListWrapper<::stringlist_t*, const char*>;


+ 42
- 45
src/types.cc View File

@ -13,31 +13,31 @@
#include <string>
#include <cstring>
namespace pEp
{
EngineError::EngineError(PEP_STATUS status, const char* message)
: std::runtime_error(
std::string{"EngineError: "}
+ (message ? '"' + std::string{message} + "\" " : std::string{} )
+ status_to_string(status)
)
{}
namespace pEp {
EngineError::EngineError(PEP_STATUS status, const char* message) :
std::runtime_error(
std::string{ "EngineError: " } +
(message ? '"' + std::string{ message } + "\" " : std::string{}) +
status_to_string(status))
{
}
////////////////
////////////////
template<>
template<>
message* Wrapper<::message*>::_new<PEP_msg_direction, const char*>(PEP_msg_direction dir, const char* src)
message* Wrapper<::message*>::_new<PEP_msg_direction, const char*>(
PEP_msg_direction dir,
const char* src)
{
message* m = nullptr;
bool pep_msg = false;
PEP_STATUS status = mime_decode_message(src, strlen(src), &m, &pep_msg);
if(status != PEP_STATUS_OK)
{
if (status != PEP_STATUS_OK) {
throw EngineError(status, "mime_decode_message()");
}
m->dir = dir;
return m;
}
@ -54,30 +54,28 @@ namespace pEp
return ::message_dup(value);
}
////////////////
////////////////
template<>
template<>
::stringpair_t* Wrapper<::stringpair_t*>::_new(const char* key, const char* value)
{
stringpair_t* sp = new_stringpair(key, value);
if(!sp)
{
if (!sp) {
throw EngineError(PEP_OUT_OF_MEMORY, "new_stringpair()");
}
return sp;
}
template<>
template<>
::stringpair_t* Wrapper<::stringpair_t*>::_new(char* key, char* value)
{
return _new<const char*, const char*>(
const_cast<const char*>(key),
const_cast<const char*>(value)
);
const_cast<const char*>(key),
const_cast<const char*>(value));
}
template<>
template<>
::stringpair_t* Wrapper<::stringpair_t*>::_new(const std::string& key, const std::string& value)
@ -102,9 +100,10 @@ namespace pEp
{
free_stringpair_list(spl);
}
template<>
stringpair_t* stringpair_list_t::* const ListWrapper<stringpair_list_t*, stringpair_t*>::Value = &stringpair_list_t::value;
stringpair_t* stringpair_list_t::*const
ListWrapper<stringpair_list_t*, stringpair_t*>::Value = &stringpair_list_t::value;
template<>
int StringPairList::size() const
@ -118,59 +117,57 @@ namespace pEp
{
return !(value && value->value);
}
template<>
void StringPairList::erase( const StringPairList::iterator& it)
void StringPairList::erase(const StringPairList::iterator& it)
{
if(it.value && it.value->value && it.value->value->key)
{
if (it.value && it.value->value && it.value->value->key) {
value = stringpair_list_delete_by_key(value, it.value->value->key);
}
}
template<>
void StringPairList::clear()
{
free_stringpair_list(value);
value = nullptr;
}
template<>
void StringPairList::push_back(::stringpair_t*&& sp)
{
auto last = stringpair_list_add(value, sp);
if(value==nullptr)
if (value == nullptr)
value = last;
sp = nullptr;
}
template<>
void StringPairList::push_back(StringPair&& sp)
{
auto last = stringpair_list_add(value, sp.move_out());
if(value==nullptr)
if (value == nullptr)
value = last;
}
template<>
ListWrapper<::stringpair_list_t*, stringpair_t*>::ListWrapper(const std::initializer_list<StringPair>& il)
: StringPairList{}
ListWrapper<::stringpair_list_t*, stringpair_t*>::ListWrapper(
const std::initializer_list<StringPair>& il) :
StringPairList{}
{
::stringpair_list_t* last = nullptr;
for(const StringPair& sp : il)
{
::stringpair_list_t* last = nullptr;
for (const StringPair& sp : il) {
last = stringpair_list_add(last, stringpair_dup(sp.get()));
if(last==nullptr)
{
if (last == nullptr) {
throw std::runtime_error("Cannot create StringPairList from {}: Out Of Memory.");
}
if(value==nullptr)
if (value == nullptr)
value = last; // save the head of linked list.
}
}
////////////////
////////////////
template class Wrapper<::pEp_identity*>;
template class Wrapper<::stringpair_t*>;


+ 6
- 8
src/types.hh View File

@ -12,23 +12,21 @@
#include <pEp/stringpair.h>
#include <pEp/message.h>
namespace pEp
{
class EngineError : std::runtime_error
{
namespace pEp {
class EngineError : std::runtime_error {
public:
EngineError(PEP_STATUS status, const char* message = nullptr);
};
using Identity = Wrapper<::pEp_identity*>;
using IdentityList = ListWrapper<::identity_list*, ::pEp_identity*>;
using StringPair = Wrapper<::stringpair_t*>;
using StringPairList = ListWrapper<::stringpair_list_t*, ::stringpair_t*>;
using StringList = ListWrapper<::stringlist_t*, const char*>;
using BlobList = ListWrapper<::bloblist_t*, void>;
using BlobList = ListWrapper<::bloblist_t*, void>;
using Message = Wrapper<::message*>;
} // end of namespace pEp


+ 221
- 183
src/wrapper.hh View File

@ -7,193 +7,231 @@
#include <initializer_list>
#include <iterator>
namespace pEp
{
/// A generalized wrapper around pEpEngine's datatypes.
template<class T>
class Wrapper
{
public:
typedef T c_type;
template<class... Args>
Wrapper(Args... args) : value{ this->_new(args...) } {}
// no implicit copying... (yet?)
Wrapper(const Wrapper<T>&) = delete;
void operator=(const Wrapper<T>&) = delete;
// must be implemented separately for each T
Wrapper(Wrapper<T>&& victim);
Wrapper<T>& operator=(Wrapper<T>&& victim);
~Wrapper();
Wrapper<T> copy() const;
bool operator==(const Wrapper<T>& b) const
{
return value==b.value;
}
bool operator!=(const Wrapper<T>& b) const
{
return value!=b.value;
}
private:
// must be defined for each wrapped type:
template<class... Args>
T _new(Args...);
T value;
};
// many wrapped datatypes are pointers, we can generalize a lot for them:
template<class T>
class Wrapper<T*>
{
public:
typedef T* c_type;
Wrapper() : value{nullptr} {}
template<class... Args>
Wrapper(Args... args) : value{ this->_new(args...) } {}
// move is easy, efficient and generic:
Wrapper(Wrapper<T*>&& victim) noexcept
: value{ victim.value}
{
victim.value = nullptr;
}
Wrapper<T*>& operator=(Wrapper<T*>&& victim) noexcept
{
_free(value);
value = victim.value;
victim.value = nullptr;
return *this;
}
Wrapper(const Wrapper<T*>& orig)
: value{ orig.copy_out() }
{}
Wrapper<T*>& operator=(const Wrapper<T*>& orig)
{
if(&orig == this) return *this;
_free(value);
value = orig.copy_out();
return *this;
}
~Wrapper()
{
_free(value);
}
bool operator==(const Wrapper<T*>& b) const
{
return value==b.value;
}
bool operator!=(const Wrapper<T*>& b) const
{
return value!=b.value;
}
// Get read-only access to the value itself
// Beware: 'const' is not transitive in C, so the 2nd indirect data
// allows r/w access!
const T* operator->() const { return value; }
const T* get() const { return value; }
// Dangerous: Get R/W access to the value!
T* operator->() { return value; }
T* get() { return value;}
// Releases ownership of the value. Wrapper becomes valueless.
T* move_out() { T* r = value; value=nullptr; return r;}
// only implemented for the datatypes where necessay.
// other implementations can follow if necessary.
T* copy_out() const;
protected:
Wrapper(T* _value) : value{_value} {}
// must be defined for each wrapped type:
template<class... Args>
T* _new(Args...);
void _free(T*);
T* value;
};
// Wraps single-linked lists and provides an interface compatible
// to std::forward_list
template<class T, class Element>
class ListWrapper;
template<class T, class Element>
class ListWrapper<T*, Element> : public Wrapper<T*>
{
public:
typedef Wrapper<T*> Base;
typedef ListWrapper<T*, Element> LW;
static Element T::* const Value; // to access the current value
// does not own the *value
class iterator : public std::iterator< std::forward_iterator_tag, Element, ptrdiff_t>
{
namespace pEp {
/// A generalized wrapper around pEpEngine's datatypes.
template<class T>
class Wrapper {
public:
iterator() = default;
iterator operator++() { return (value ? value = value->next : value); }
Element operator*() { return value->*LW::Value; }
Element operator->() { return value->*LW::Value; }
bool operator==(const iterator& other) const { return value == other.value; }
bool operator!=(const iterator& other) const { return value != other.value; }
typedef T c_type;
template<class... Args>
Wrapper(Args... args) : value{ this->_new(args...) }
{
}
// no implicit copying... (yet?)
Wrapper(const Wrapper<T>&) = delete;
void operator=(const Wrapper<T>&) = delete;
// must be implemented separately for each T
Wrapper(Wrapper<T>&& victim);
Wrapper<T>& operator=(Wrapper<T>&& victim);
~Wrapper();
Wrapper<T> copy() const;
bool operator==(const Wrapper<T>& b) const
{
return value == b.value;
}
bool operator!=(const Wrapper<T>& b) const
{
return value != b.value;
}
private:
iterator(T* _t) : value{_t} {}
T* value = nullptr;
friend class ListWrapper<T*, Element>;
// must be defined for each wrapped type:
template<class... Args>
T _new(Args...);
T value;
};
// many wrapped datatypes are pointers, we can generalize a lot for them:
template<class T>
class Wrapper<T*> {
public:
typedef T* c_type;
Wrapper() : value{ nullptr } {}
template<class... Args>
Wrapper(Args... args) : value{ this->_new(args...) }
{
}
// move is easy, efficient and generic:
Wrapper(Wrapper<T*>&& victim) noexcept : value{ victim.value }
{
victim.value = nullptr;
}
Wrapper<T*>& operator=(Wrapper<T*>&& victim) noexcept
{
_free(value);
value = victim.value;
victim.value = nullptr;
return *this;
}
Wrapper(const Wrapper<T*>& orig) : value{ orig.copy_out() } {}
Wrapper<T*>& operator=(const Wrapper<T*>& orig)
{
if (&orig == this)
return *this;
_free(value);
value = orig.copy_out();
return *this;
}
~Wrapper()
{
_free(value);
}
bool operator==(const Wrapper<T*>& b) const
{
return value == b.value;
}
bool operator!=(const Wrapper<T*>& b) const
{
return value != b.value;
}
// Get read-only access to the value itself
// Beware: 'const' is not transitive in C, so the 2nd indirect data
// allows r/w access!
const T* operator->() const
{
return value;
}
const T* get() const
{
return value;
}
// Dangerous: Get R/W access to the value!
T* operator->()
{
return value;
}
T* get()
{
return value;
}
// Releases ownership of the value. Wrapper becomes valueless.
T* move_out()
{
T* r = value;
value = nullptr;
return r;
}
// only implemented for the datatypes where necessay.
// other implementations can follow if necessary.
T* copy_out() const;
protected:
Wrapper(T* _value) : value{ _value } {}
// must be defined for each wrapped type:
template<class... Args>
T* _new(Args...);
void _free(T*);
T* value;
};
// Wraps single-linked lists and provides an interface compatible
// to std::forward_list
template<class T, class Element>
class ListWrapper;
template<class T, class Element>
class ListWrapper<T*, Element> : public Wrapper<T*> {
public:
typedef Wrapper<T*> Base;
typedef ListWrapper<T*, Element> LW;
static Element T::*const Value; // to access the current value
// does not own the *value
class iterator : public std::iterator<std::forward_iterator_tag, Element, ptrdiff_t> {
public:
iterator() = default;
iterator operator++()
{
return (value ? value = value->next : value);
}
Element operator*()
{
return value->*LW::Value;
}
Element operator->()
{
return value->*LW::Value;
}
bool operator==(const iterator& other) const
{
return value == other.value;
}
bool operator!=(const iterator& other) const
{
return value != other.value;
}
private:
iterator(T* _t) : value{ _t } {}
T* value = nullptr;
friend class ListWrapper<T*, Element>;
};
typedef const iterator const_iterator;
using Base::value;
ListWrapper() : Base() {}
ListWrapper(const std::initializer_list<pEp::Wrapper<Element>>& i);
ListWrapper(const std::initializer_list<Element>& i);
iterator begin()
{
return iterator{ value };
}
iterator end() const
{
return iterator{};
}
const_iterator cbegin() const
{
return const_iterator{ value };
}
const_iterator cend() const
{
return const_iterator{};
}
int size() const;
bool empty() const;
void erase(const iterator& it);
void clear();
void push_back(Element&&);
void push_back(Wrapper<Element>&&);
};
typedef const iterator const_iterator;
using Base::value;
ListWrapper() : Base() {}
ListWrapper(const std::initializer_list<pEp::Wrapper<Element>>& i);
ListWrapper(const std::initializer_list<Element>& i);
iterator begin() { return iterator{value}; }
iterator end() const { return iterator{}; }
const_iterator cbegin() const { return const_iterator{value}; }
const_iterator cend() const { return const_iterator{}; }
int size() const;
bool empty() const;
void erase(const iterator& it);
void clear();
void push_back(Element&&);
void push_back(Wrapper<Element>&&);
};
} // end of namespace pEp


+ 19
- 13
test/unittest_identity.cc View File

@ -3,32 +3,38 @@
#include "../src/types.hh"
TEST( PepIdentity, Simple )
TEST(PepIdentity, Simple)
{
pEp::Identity id{"test1@pEpdatatypes.lol", "FF00112233445566778899AABBCCDDEEFF001122", "Test User ID", "Test User Name"};
pEp::Identity id{ "test1@pEpdatatypes.lol",
"FF00112233445566778899AABBCCDDEEFF001122",
"Test User ID",
"Test User Name" };
}
TEST( IdentityList, Simple )
TEST(IdentityList, Simple)
{
pEp::IdentityList il;
EXPECT_TRUE(il.empty());
EXPECT_EQ(il.size(), 0);
}
TEST( IdentityList, InitList )
TEST(IdentityList, InitList)
{
pEp::IdentityList il(
{
pEp::Identity{"test-init1@pEpdatatypes.lol", "0100112233445566778899AABBCCDDEEFF001122", "Test User ID1", "Test User 1 Name"},
pEp::Identity{"test-init2@pEpdatatypes.lol", "0200112233445566778899AABBCCDDEEFF001122", "Test User ID2", "Test User 2 Name"}
} );
EXPECT_EQ( il.size(), 2);
pEp::IdentityList il({ pEp::Identity{ "test-init1@pEpdatatypes.lol",
"0100112233445566778899AABBCCDDEEFF001122",
"Test User ID1",
"Test User 1 Name" },
pEp::Identity{ "test-init2@pEpdatatypes.lol",
"0200112233445566778899AABBCCDDEEFF001122",
"Test User ID2",
"Test User 2 Name" } });
EXPECT_EQ(il.size(), 2);
il.clear();
EXPECT_EQ(il.size(), 0);
EXPECT_TRUE( il.empty() );
EXPECT_TRUE(il.empty());
}


+ 119
- 120
test/unittest_message.cc View File

@ -2,113 +2,112 @@
#include "../src/types.hh"
namespace
{
static const char* mail1_eml =
"Return-Path: <alice@pep-project.org>\r\n"
"X-Original-To: alice@pep-project.org\r\n"
"Delivered-To: alice@pep-project.org\r\n"
"Received: from localhost (localhost [127.0.0.1])\r\n"
"\tby dragon.pibit.ch (Postfix) with ESMTP id B84AF171C06F\r\n"
"\tfor <alice@pep-project.org>; Wed, 16 Jan 2019 16:29:39 +0100 (CET)\r\n"
"Received: from dragon.pibit.ch ([127.0.0.1])\r\n"
"\tby localhost (dragon.pibit.ch [127.0.0.1]) (amavisd-new, port 10024)\r\n"
"\twith ESMTP id q0wZqHMoT1gS for <alice@pep-project.org>;\r\n"
"\tWed, 16 Jan 2019 16:29:37 +0100 (CET)\r\n"
"Received: from Alice-PC.local (unknown [192.168.128.20])\r\n"
"\tby dragon.pibit.ch (Postfix) with ESMTPSA id 563DD171C06A\r\n"
"\tfor <alice@pep-project.org>; Wed, 16 Jan 2019 16:29:37 +0100 (CET)\r\n"
"To: Bob <bob@pep-project.org>\r\n"
"From: Alice <alice@pep-project.org>\r\n"
"Cc: Carol Couscous <carol.couscous+private@pep.lol>, Dave Doe (III) \r\n"
" Dexter <dave-dexter@pep.ooo>, dodo@pep.lol, \"Eve @ Evil\" <eve@evil.lol>, \r\n"
" Mallory =?UTF-8?B?TcO2bGxlcg==?= (private) <\"mallory @ moeller\"@sinister.aq>\r\n"
"Subject: =?UTF-8?B?UsO4ZGdyw7hkIG1lZCBmbMO4ZGU=?=\r\n"
"Openpgp: preference=signencrypt\r\n"
"Organization: =?UTF-8?B?8J+Ukg==?=\r\n"
"Message-ID: <65a2df2c-ddc8-0875-a142-21acf62ed467@pep-project.org>\r\n"
"References: <msg-alfa@pep.id> <msg-bravo@pep.aq> <lol-123456789@intern.sc.ful-lol.example>\r\n"
" <msg-charlie@pep.aq>\r\n"
"In-Reply-To: <msg-reply-0815@pep.aq>\r\n"
"Date: Wed, 16 Jan 2019 16:29:30 +0100\r\n"
"User-Agent: B\r\n"
"MIME-Version: 1.0\r\n"
"Content-Type: multipart/mixed;\r\n"
" boundary=\"==pEp_01==\"\r\n"
"\r\n"
"This is a Multipart MIME message.\r\n"
"--==pEp_01==\r\n"
"Content-Type: multipart/alternative; boundary=\"==pEp_02==\";\r\n"
" protected-headers=\"v1\"\r\n"
"\r\n"
"--==pEp_02==\r\n"
"Content-Type: text/plain; charset=\"utf-8\"\r\n"
"Content-Language: en-US\r\n"
"Content-Transfer-Encoding: quoted-printable\r\n"
"\r\n"
"R=C3=B8dgr=C3=B8d med fl=C3=B8de?\r\n"
"\r\n"
"--==pEp_02==\r\n"
"Content-Type: multipart/related; boundary=\"==pEp_LoL==\";\r\n"
"\r\n"
"--==pEp_LoL==\r\n"
"Content-Type: text/html; charset=\"ISO-8859-1\";\r\n"
"Content-Transfer-Encoding: quoted-printable\r\n"
"\r\n"
"<html lang=3D=22de=22><body>=DCbergr=F6=DFen=E4nderung: 1=\r\n"
"0=80.</body></html>\r\n"
"\r\n"
"--==pEp_LoL==\r\n"
"Content-Type: image/png; name=\"rebeccapurple-circle.png\"\r\n"
"Content-Language: en-US\r\n"
"Content-ID: <rebeccapurple-circle-fb25fbb3-fd0b-46af-b567-7d1aa5725c49@pep.lol>\r\n"
"Content-Transfer-Encoding: base64\r\n"
"Content-Disposition: inline;\r\n"
" filename*0*=utf-8'en-US'rebeccapurple;\r\n"
" filename*1*=%2Dcircle.png;\r\n"
"\r\n"
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEVmM5n///9dvR/iAAAA\r\n"
"H0lEQVQIHWP4Ic/wgJ3hADNDAyMIYQKIOFABUNkPeQC4LQeH3BOsvgAAAABJRU5ErkJggg==\r\n"
"\r\n"
"--==pEp_LoL==--\r\n" // end of multipart/related
"\r\n"
"--==pEp_02==--\r\n" // end of multipart/alternative
"\r\n"
"--==pEp_01==\r\n" // first "real" attachment, 2nd in bloblist
"Content-Type: application/octet-stream; name=\"This is a long\r\n"
" file name so it is split to multiple\r\n"
" physical lines.bin\"\r\n"
"Content-Language: en-US\r\n"
"Content-Transfer-Encoding: base64\r\n"
"Content-Disposition: attachment;\r\n"
" filename*0=\"This is a long file name so it is split to\";\r\n"
" filename*1=\" multiple physical lines.bin\";\r\n"
"\r\n"
"w5xiZXJncsO2w59lbsOkbmRlcnVuZyEK\r\n"
"\r\n"
"--==pEp_01==\r\n" // another text/plain part, 3rd in bloblist
"Content-Type: text/plain; charset=\"ISO-8859-15\";\r\n"
"Content-Transfer-Encoding: quoted-printable\r\n"
"\r\n"
"=DCbergr=F6=DFen=E4nderung: 10=A4.\r\n"
"--==pEp_01==\r\n" // an attached PNG image with bizarre filename as 4th and last element in bloblist
"Content-Type: image/png; name=\"=?UTF-8?B?8J+SqSDwn5iAIPCf?="
" =?UTF-8?B?kqkg8J+YgCDwn5KpIPCfmIAg8J+SqSDwn5iAIPCfkqkg8J+YgCDwn5KpIPCfm?="
" =?UTF-8?B?IAg8J+SqSDwn5iAIPCfkqkg8J+YgC5wbmc=?=\"\r\n"
"Content-Language: en-US\r\n"
"Content-Transfer-Encoding: base64\r\n"
"Content-Disposition: attachment;\r\n"
" filename*0*=utf-8''%F0%9F%92%A9%20%F0%9F%98%80%20%F0%9F%92%A9%20%F0;\r\n"
" filename*1*=%9F%98%80%20%F0%9F%92%A9%20%F0%9F%98%80%20%F0%9F%92%A9;\r\n"
" filename*2*=%20%F0%9F%98%80%20%F0%9F%92%A9%20%F0%9F%98%80%20%F0%9F;\r\n"
" filename*3*=%92%A9%20%F0%9F%98%80%20%F0%9F%92%A9%20%F0%9F%98%80%20;\r\n"
" filename*4*=%F0%9F%92%A9%20%F0%9F%98%80.png\r\n"
"\r\n"
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEVmM5n///9dvR/iAAAA\r\n"
" H0lEQVQIHWP4Ic/wgJ3hADN\r\n"
"DAyMIYQKIOFABUNkPeQC4LQeH3BOsvgAAAABJRU5ErkJggg==\r\n"
"--==pEp_01==--\r\n"
"\r\n";
namespace {
static const char*
mail1_eml = "Return-Path: <alice@pep-project.org>\r\n"
"X-Original-To: alice@pep-project.org\r\n"
"Delivered-To: alice@pep-project.org\r\n"
"Received: from localhost (localhost [127.0.0.1])\r\n"
"\tby dragon.pibit.ch (Postfix) with ESMTP id B84AF171C06F\r\n"
"\tfor <alice@pep-project.org>; Wed, 16 Jan 2019 16:29:39 +0100 (CET)\r\n"
"Received: from dragon.pibit.ch ([127.0.0.1])\r\n"
"\tby localhost (dragon.pibit.ch [127.0.0.1]) (amavisd-new, port 10024)\r\n"
"\twith ESMTP id q0wZqHMoT1gS for <alice@pep-project.org>;\r\n"
"\tWed, 16 Jan 2019 16:29:37 +0100 (CET)\r\n"
"Received: from Alice-PC.local (unknown [192.168.128.20])\r\n"
"\tby dragon.pibit.ch (Postfix) with ESMTPSA id 563DD171C06A\r\n"
"\tfor <alice@pep-project.org>; Wed, 16 Jan 2019 16:29:37 +0100 (CET)\r\n"
"To: Bob <bob@pep-project.org>\r\n"
"From: Alice <alice@pep-project.org>\r\n"
"Cc: Carol Couscous <carol.couscous+private@pep.lol>, Dave Doe (III) \r\n"
" Dexter <dave-dexter@pep.ooo>, dodo@pep.lol, \"Eve @ Evil\" <eve@evil.lol>, \r\n"
" Mallory =?UTF-8?B?TcO2bGxlcg==?= (private) <\"mallory @ moeller\"@sinister.aq>\r\n"
"Subject: =?UTF-8?B?UsO4ZGdyw7hkIG1lZCBmbMO4ZGU=?=\r\n"
"Openpgp: preference=signencrypt\r\n"
"Organization: =?UTF-8?B?8J+Ukg==?=\r\n"
"Message-ID: <65a2df2c-ddc8-0875-a142-21acf62ed467@pep-project.org>\r\n"
"References: <msg-alfa@pep.id> <msg-bravo@pep.aq> <lol-123456789@intern.sc.ful-lol.example>\r\n"
" <msg-charlie@pep.aq>\r\n"
"In-Reply-To: <msg-reply-0815@pep.aq>\r\n"
"Date: Wed, 16 Jan 2019 16:29:30 +0100\r\n"
"User-Agent: B\r\n"
"MIME-Version: 1.0\r\n"
"Content-Type: multipart/mixed;\r\n"
" boundary=\"==pEp_01==\"\r\n"
"\r\n"
"This is a Multipart MIME message.\r\n"
"--==pEp_01==\r\n"
"Content-Type: multipart/alternative; boundary=\"==pEp_02==\";\r\n"
" protected-headers=\"v1\"\r\n"
"\r\n"
"--==pEp_02==\r\n"
"Content-Type: text/plain; charset=\"utf-8\"\r\n"
"Content-Language: en-US\r\n"
"Content-Transfer-Encoding: quoted-printable\r\n"
"\r\n"
"R=C3=B8dgr=C3=B8d med fl=C3=B8de?\r\n"
"\r\n"
"--==pEp_02==\r\n"
"Content-Type: multipart/related; boundary=\"==pEp_LoL==\";\r\n"
"\r\n"
"--==pEp_LoL==\r\n"
"Content-Type: text/html; charset=\"ISO-8859-1\";\r\n"
"Content-Transfer-Encoding: quoted-printable\r\n"
"\r\n"
"<html lang=3D=22de=22><body>=DCbergr=F6=DFen=E4nderung: 1=\r\n"
"0=80.</body></html>\r\n"
"\r\n"
"--==pEp_LoL==\r\n"
"Content-Type: image/png; name=\"rebeccapurple-circle.png\"\r\n"
"Content-Language: en-US\r\n"
"Content-ID: <rebeccapurple-circle-fb25fbb3-fd0b-46af-b567-7d1aa5725c49@pep.lol>\r\n"
"Content-Transfer-Encoding: base64\r\n"
"Content-Disposition: inline;\r\n"
" filename*0*=utf-8'en-US'rebeccapurple;\r\n"
" filename*1*=%2Dcircle.png;\r\n"
"\r\n"
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEVmM5n///9dvR/iAAAA\r\n"
"H0lEQVQIHWP4Ic/wgJ3hADNDAyMIYQKIOFABUNkPeQC4LQeH3BOsvgAAAABJRU5ErkJggg==\r\n"
"\r\n"
"--==pEp_LoL==--\r\n" // end of multipart/related
"\r\n"
"--==pEp_02==--\r\n" // end of multipart/alternative
"\r\n"
"--==pEp_01==\r\n" // first "real" attachment, 2nd in bloblist
"Content-Type: application/octet-stream; name=\"This is a long\r\n"
" file name so it is split to multiple\r\n"
" physical lines.bin\"\r\n"
"Content-Language: en-US\r\n"
"Content-Transfer-Encoding: base64\r\n"
"Content-Disposition: attachment;\r\n"
" filename*0=\"This is a long file name so it is split to\";\r\n"
" filename*1=\" multiple physical lines.bin\";\r\n"
"\r\n"
"w5xiZXJncsO2w59lbsOkbmRlcnVuZyEK\r\n"
"\r\n"
"--==pEp_01==\r\n" // another text/plain part, 3rd in bloblist
"Content-Type: text/plain; charset=\"ISO-8859-15\";\r\n"
"Content-Transfer-Encoding: quoted-printable\r\n"
"\r\n"
"=DCbergr=F6=DFen=E4nderung: 10=A4.\r\n"
"--==pEp_01==\r\n" // an attached PNG image with bizarre filename as 4th and last element in bloblist
"Content-Type: image/png; name=\"=?UTF-8?B?8J+SqSDwn5iAIPCf?="
" =?UTF-8?B?kqkg8J+YgCDwn5KpIPCfmIAg8J+SqSDwn5iAIPCfkqkg8J+YgCDwn5KpIPCfm?="
" =?UTF-8?B?IAg8J+SqSDwn5iAIPCfkqkg8J+YgC5wbmc=?=\"\r\n"
"Content-Language: en-US\r\n"
"Content-Transfer-Encoding: base64\r\n"
"Content-Disposition: attachment;\r\n"
" filename*0*=utf-8''%F0%9F%92%A9%20%F0%9F%98%80%20%F0%9F%92%A9%20%F0;\r\n"
" filename*1*=%9F%98%80%20%F0%9F%92%A9%20%F0%9F%98%80%20%F0%9F%92%A9;\r\n"
" filename*2*=%20%F0%9F%98%80%20%F0%9F%92%A9%20%F0%9F%98%80%20%F0%9F;\r\n"
" filename*3*=%92%A9%20%F0%9F%98%80%20%F0%9F%92%A9%20%F0%9F%98%80%20;\r\n"
" filename*4*=%F0%9F%92%A9%20%F0%9F%98%80.png\r\n"
"\r\n"
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEVmM5n///9dvR/iAAAA\r\n"
" H0lEQVQIHWP4Ic/wgJ3hADN\r\n"
"DAyMIYQKIOFABUNkPeQC4LQeH3BOsvgAAAABJRU5ErkJggg==\r\n"
"--==pEp_01==--\r\n"
"\r\n";
PEP_STATUS dummy_message(::message* msg)
@ -120,21 +119,21 @@ namespace
} // end of anonymous namespace
TEST( MessageTest, Simple )
TEST(MessageTest, Simple)
{
pEp::Message msg{PEP_dir_outgoing, mail1_eml};
pEp::Message msg{ PEP_dir_outgoing, mail1_eml };
EXPECT_EQ(msg->dir, PEP_dir_outgoing);
EXPECT_STREQ( msg->shortmsg, "Rødgrød med fløde" );
EXPECT_STREQ( msg->longmsg , "Rødgrød med fløde?\r\n" );
EXPECT_EQ( identity_list_length(msg->to), 1 );
EXPECT_EQ( identity_list_length(msg->cc), 5 );
EXPECT_EQ( identity_list_length(msg->bcc), 0 );
EXPECT_EQ( bloblist_length(msg->attachments), 4 );
EXPECT_STREQ(msg->shortmsg, "Rødgrød med fløde");
EXPECT_STREQ(msg->longmsg, "Rødgrød med fløde?\r\n");
EXPECT_EQ(identity_list_length(msg->to), 1);
EXPECT_EQ(identity_list_length(msg->cc), 5);
EXPECT_EQ(identity_list_length(msg->bcc), 0);
EXPECT_EQ(bloblist_length(msg->attachments), 4);
ASSERT_NE(msg->from, nullptr);
EXPECT_STREQ( msg->from->username, "Alice");
EXPECT_EQ( dummy_message(msg.get()), PEP_STATUS_OK);
EXPECT_STREQ( msg->shortmsg, "Hello World");
EXPECT_STREQ(msg->from->username, "Alice");
EXPECT_EQ(dummy_message(msg.get()), PEP_STATUS_OK);
EXPECT_STREQ(msg->shortmsg, "Hello World");
}

+ 73
- 61
test/unittest_nfc.cc View File

@ -1,6 +1,6 @@
#include <gtest/gtest.h>
#include "../src/nfc.hh" // for illegal_utf8 exception
#include "../src/nfc.hh" // for illegal_utf8 exception
#include <vector>
using namespace pEp;
@ -8,70 +8,82 @@ using std::string_view;
namespace {
struct TestEntry
{
string_view input;
bool is_nfc;
IsNFC quick;
string_view nfc;
struct TestEntry {
string_view input;
bool is_nfc;
IsNFC quick;
string_view nfc;
};
typedef TestEntry TE;
std::ostream& operator<<(std::ostream& o, const TestEntry& tt)
{
return o << "input=«" << tt.input << "», isNfc=" << tt.is_nfc << ", quick=" << tt.quick
<< ". ";
}
const char nullo[4] = { 0, 0, 0, 0 };
const std::vector<TestEntry> testValues = {
{ "", true, IsNFC::Yes, "" }, // always start with the simple case ;-)
{ "123", true, IsNFC::Yes, "123" }, // some ASCII digits. Still easy.
{ "\n\\\b", true, IsNFC::Yes, "\n\\\b" }, // backslash escapes for ASCII and control chars
{ "ä", true, IsNFC::Yes, "ä" }, // <U+00E4> small a with diaeresis
{ "\xc4\x85", true, IsNFC::Yes, "\xc4\x85" }, // <U+0105> small a with ogonek
{ "a\xcc\x88", false, IsNFC::Maybe, "ä" }, // a + <U+0308> combining diaresis
{ "a\xcc\xa8", false, IsNFC::Maybe, "\xc4\x85" }, // a + <U+0328> combining ogonek
{ "a\xcc\xa8\xcc\x88",
false,
IsNFC::Maybe,
"\xc4\x85\xcc\x88" }, // a + <U+0328> + <U+0308> (ogonek + diaeresis)
{ "a\xcc\x88\xcc\xa8",
false,
IsNFC::Maybe,
"\xc4\x85\xcc\x88" }, // a + <U+0308> + <U+0328> (diaeresis + ogonek)
{ "\xc4\x85\xcc\x88",
true,
IsNFC::Maybe,
"\xc4\x85\xcc\x88" }, // <U+0105> small a with ogonek + combining diaeresis
{ "ä\xcc\xa8", false, IsNFC::Maybe, "\xc4\x85\xcc\x88" }, // a diaeresis + <U+0328> combining ogonek
// Already implemented, because <U+305> and <U+33C> have neither "No" nor "Maybe" NFC class:
{ "a\xcc\x85\xcc\xbc",
false,
IsNFC::No,
"a\xcc\xbc\xcc\x85" }, // a + <U+0305> + <U+033C> (overline + seagull_below)
{ "a\xcc\xbc\xcc\x85",
true,
IsNFC::Yes,
"a\xcc\xbc\xcc\x85" }, // a + <U+033C> + <U+0305> (seagull_below + overline)
{ string_view(nullo, 1), true, IsNFC::Yes, string_view(nullo, 1) }, // Yeah, 1 NUL byte
{ string_view(nullo, 4), true, IsNFC::Yes, string_view(nullo, 4) }, // Yeah, 4 NUL bytes
{ "EOF", true, IsNFC::Yes, "EOF" }
};
} // namespace
class NfcTest : public ::testing::TestWithParam<TestEntry> {
// intentionally left blank for now.
};
typedef TestEntry TE;
std::ostream& operator<<(std::ostream& o, const TestEntry& tt)
{
return o << "input=«" << tt.input << "», isNfc=" << tt.is_nfc << ", quick=" << tt.quick << ". ";
}
const char nullo[4] = {0,0,0,0};
const std::vector<TestEntry> testValues =
{
{ "" , true, IsNFC::Yes, "" }, // always start with the simple case ;-)
{ "123" , true, IsNFC::Yes, "123" }, // some ASCII digits. Still easy.
{ "\n\\\b" , true, IsNFC::Yes, "\n\\\b" }, // backslash escapes for ASCII and control chars
{ "ä" , true, IsNFC::Yes, "ä" }, // <U+00E4> small a with diaeresis
{ "\xc4\x85" , true, IsNFC::Yes, "\xc4\x85" }, // <U+0105> small a with ogonek
INSTANTIATE_TEST_SUITE_P(NfcTestInstance, NfcTest, testing::ValuesIn(testValues));
{ "a\xcc\x88", false, IsNFC::Maybe, "ä" }, // a + <U+0308> combining diaresis
{ "a\xcc\xa8", false, IsNFC::Maybe, "\xc4\x85" }, // a + <U+0328> combining ogonek
{ "a\xcc\xa8\xcc\x88", false, IsNFC::Maybe, "\xc4\x85\xcc\x88" }, // a + <U+0328> + <U+0308> (ogonek + diaeresis)
{ "a\xcc\x88\xcc\xa8", false, IsNFC::Maybe, "\xc4\x85\xcc\x88" }, // a + <U+0308> + <U+0328> (diaeresis + ogonek)
{ "\xc4\x85\xcc\x88" , true, IsNFC::Maybe, "\xc4\x85\xcc\x88" }, // <U+0105> small a with ogonek + combining diaeresis
{ "ä\xcc\xa8" , false, IsNFC::Maybe, "\xc4\x85\xcc\x88" }, // a diaeresis + <U+0328> combining ogonek
// Already implemented, because <U+305> and <U+33C> have neither "No" nor "Maybe" NFC class:
{ "a\xcc\x85\xcc\xbc", false, IsNFC::No , "a\xcc\xbc\xcc\x85"}, // a + <U+0305> + <U+033C> (overline + seagull_below)
{ "a\xcc\xbc\xcc\x85", true, IsNFC::Yes , "a\xcc\xbc\xcc\x85"}, // a + <U+033C> + <U+0305> (seagull_below + overline)
{ string_view(nullo, 1), true, IsNFC::Yes, string_view(nullo, 1) }, // Yeah, 1 NUL byte
{ string_view(nullo, 4), true, IsNFC::Yes, string_view(nullo, 4) }, // Yeah, 4 NUL bytes
{ "EOF", true, IsNFC::Yes, "EOF" }
};
}
class NfcTest : public ::testing::TestWithParam<TestEntry>
TEST_P(NfcTest, Meh)
{
// intentionally left blank for now.
};
const auto& v = GetParam();
EXPECT_EQ(v.quick, UTF8::isNFC_quick_check(v.input));
INSTANTIATE_TEST_SUITE_P(NfcTestInstance, NfcTest, testing::ValuesIn(testValues) );
EXPECT_EQ(v.is_nfc, UTF8::isNFC(v.input));
EXPECT_EQ(v.nfc, UTF8::toNFC(v.input));
TEST_P( NfcTest, Meh )
{
const auto& v = GetParam();
EXPECT_EQ( v.quick, UTF8::isNFC_quick_check(v.input) );
EXPECT_EQ( v.is_nfc, UTF8::isNFC(v.input) );
EXPECT_EQ( v.nfc , UTF8::toNFC(v.input) );
if(v.is_nfc)
{