Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
6311e886
Unverified
Commit
6311e886
authored
Mar 23, 2018
by
Edward Thomson
Committed by
GitHub
Mar 23, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4594 from pks-t/pks/mempack-assert
odb: fix writing to fake write streams
parents
72e60347
a52b4c51
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
1 deletions
+61
-1
src/odb.c
+1
-1
tests/odb/backend/mempack.c
+60
-0
No files found.
src/odb.c
View file @
6311e886
...
@@ -369,7 +369,7 @@ static int fake_wstream__write(git_odb_stream *_stream, const char *data, size_t
...
@@ -369,7 +369,7 @@ static int fake_wstream__write(git_odb_stream *_stream, const char *data, size_t
{
{
fake_wstream
*
stream
=
(
fake_wstream
*
)
_stream
;
fake_wstream
*
stream
=
(
fake_wstream
*
)
_stream
;
assert
(
stream
->
written
+
len
>
stream
->
size
);
assert
(
stream
->
written
+
len
<=
stream
->
size
);
memcpy
(
stream
->
buffer
+
stream
->
written
,
data
,
len
);
memcpy
(
stream
->
buffer
+
stream
->
written
,
data
,
len
);
stream
->
written
+=
len
;
stream
->
written
+=
len
;
...
...
tests/odb/backend/mempack.c
0 → 100644
View file @
6311e886
#include "clar_libgit2.h"
#include "repository.h"
#include "backend_helpers.h"
#include "git2/sys/mempack.h"
static
git_odb
*
_odb
;
static
git_oid
_oid
;
static
git_odb_object
*
_obj
;
static
git_repository
*
_repo
;
void
test_odb_backend_mempack__initialize
(
void
)
{
git_odb_backend
*
backend
;
cl_git_pass
(
git_mempack_new
(
&
backend
));
cl_git_pass
(
git_odb_new
(
&
_odb
));
cl_git_pass
(
git_odb_add_backend
(
_odb
,
backend
,
10
));
cl_git_pass
(
git_repository_wrap_odb
(
&
_repo
,
_odb
));
}
void
test_odb_backend_mempack__cleanup
(
void
)
{
git_odb_object_free
(
_obj
);
git_odb_free
(
_odb
);
git_repository_free
(
_repo
);
}
void
test_odb_backend_mempack__write_succeeds
(
void
)
{
const
char
*
data
=
"data"
;
cl_git_pass
(
git_odb_write
(
&
_oid
,
_odb
,
data
,
strlen
(
data
)
+
1
,
GIT_OBJ_BLOB
));
cl_git_pass
(
git_odb_read
(
&
_obj
,
_odb
,
&
_oid
));
}
void
test_odb_backend_mempack__read_of_missing_object_fails
(
void
)
{
cl_git_pass
(
git_oid_fromstr
(
&
_oid
,
"f6ea0495187600e7b2288c8ac19c5886383a4633"
));
cl_git_fail_with
(
GIT_ENOTFOUND
,
git_odb_read
(
&
_obj
,
_odb
,
&
_oid
));
}
void
test_odb_backend_mempack__exists_of_missing_object_fails
(
void
)
{
cl_git_pass
(
git_oid_fromstr
(
&
_oid
,
"f6ea0495187600e7b2288c8ac19c5886383a4633"
));
cl_assert
(
git_odb_exists
(
_odb
,
&
_oid
)
==
0
);
}
void
test_odb_backend_mempack__exists_with_existing_objects_succeeds
(
void
)
{
const
char
*
data
=
"data"
;
cl_git_pass
(
git_odb_write
(
&
_oid
,
_odb
,
data
,
strlen
(
data
)
+
1
,
GIT_OBJ_BLOB
));
cl_assert
(
git_odb_exists
(
_odb
,
&
_oid
)
==
1
);
}
void
test_odb_backend_mempack__blob_create_frombuffer_succeeds
(
void
)
{
const
char
*
data
=
"data"
;
cl_git_pass
(
git_blob_create_frombuffer
(
&
_oid
,
_repo
,
data
,
strlen
(
data
)
+
1
));
cl_assert
(
git_odb_exists
(
_odb
,
&
_oid
)
==
1
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment