@@ -49,7 +49,7 @@ TEST_P(FileDataLoaderTest, InBoundsLoadsSucceed) {
49
49
50
50
// Wrap it in a loader.
51
51
Result<FileDataLoader> fdl =
52
- FileDataLoader::From (tf.path ().c_str (), alignment ());
52
+ FileDataLoader::from (tf.path ().c_str (), alignment ());
53
53
ASSERT_EQ (fdl.error (), Error::Ok);
54
54
55
55
// size() should succeed and reflect the total size.
@@ -113,7 +113,7 @@ TEST_P(FileDataLoaderTest, OutOfBoundsLoadFails) {
113
113
TempFile tf (data, sizeof (data));
114
114
115
115
Result<FileDataLoader> fdl =
116
- FileDataLoader::From (tf.path ().c_str (), alignment ());
116
+ FileDataLoader::from (tf.path ().c_str (), alignment ());
117
117
ASSERT_EQ (fdl.error (), Error::Ok);
118
118
119
119
// Loading beyond the end of the data should fail.
@@ -133,7 +133,7 @@ TEST_P(FileDataLoaderTest, OutOfBoundsLoadFails) {
133
133
134
134
TEST_P (FileDataLoaderTest, FromMissingFileFails) {
135
135
// Wrapping a file that doesn't exist should fail.
136
- Result<FileDataLoader> fdl = FileDataLoader::From (
136
+ Result<FileDataLoader> fdl = FileDataLoader::from (
137
137
" /tmp/FILE_DOES_NOT_EXIST_EXECUTORCH_MMAP_LOADER_TEST" );
138
138
EXPECT_NE (fdl.error (), Error::Ok);
139
139
}
@@ -145,15 +145,15 @@ TEST_P(FileDataLoaderTest, BadAlignmentFails) {
145
145
146
146
// Creating a loader with default alignment works fine.
147
147
{
148
- Result<FileDataLoader> fdl = FileDataLoader::From (tf.path ().c_str ());
148
+ Result<FileDataLoader> fdl = FileDataLoader::from (tf.path ().c_str ());
149
149
ASSERT_EQ (fdl.error (), Error::Ok);
150
150
}
151
151
152
152
// Bad alignments fail.
153
153
const std::vector<size_t > bad_alignments = {0 , 3 , 5 , 17 };
154
154
for (size_t bad_alignment : bad_alignments) {
155
155
Result<FileDataLoader> fdl =
156
- FileDataLoader::From (tf.path ().c_str (), bad_alignment);
156
+ FileDataLoader::from (tf.path ().c_str (), bad_alignment);
157
157
ASSERT_EQ (fdl.error (), Error::InvalidArgument);
158
158
}
159
159
}
@@ -164,7 +164,7 @@ TEST_P(FileDataLoaderTest, MoveCtor) {
164
164
std::string contents = " FILE_CONTENTS" ;
165
165
TempFile tf (contents);
166
166
Result<FileDataLoader> fdl =
167
- FileDataLoader::From (tf.path ().c_str (), alignment ());
167
+ FileDataLoader::from (tf.path ().c_str (), alignment ());
168
168
ASSERT_EQ (fdl.error (), Error::Ok);
169
169
EXPECT_EQ (fdl->size ().get (), contents.size ());
170
170
@@ -184,6 +184,26 @@ TEST_P(FileDataLoaderTest, MoveCtor) {
184
184
EXPECT_EQ (0 , std::memcmp (fb->data (), contents.data (), fb->size ()));
185
185
}
186
186
187
+ // Test that the deprecated From method (capital 'F') still works.
188
+ TEST_P (FileDataLoaderTest, DEPRECATEDFrom) {
189
+ // Write some heterogeneous data to a file.
190
+ uint8_t data[256 ];
191
+ for (int i = 0 ; i < sizeof (data); ++i) {
192
+ data[i] = i;
193
+ }
194
+ TempFile tf (data, sizeof (data));
195
+
196
+ // Wrap it in a loader.
197
+ Result<FileDataLoader> fdl =
198
+ FileDataLoader::From (tf.path ().c_str (), alignment ());
199
+ ASSERT_EQ (fdl.error (), Error::Ok);
200
+
201
+ // size() should succeed and reflect the total size.
202
+ Result<size_t > size = fdl->size ();
203
+ ASSERT_EQ (size.error (), Error::Ok);
204
+ EXPECT_EQ (*size, sizeof (data));
205
+ }
206
+
187
207
// Run all FileDataLoaderTests multiple times, varying the return value of
188
208
// `GetParam()` based on the `testing::Values` list. The tests will interpret
189
209
// the value as "alignment".
0 commit comments