products/Sources/formale Sprachen/C/Firefox/xpcom/tests/gtest/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 19 kB image not shown  

Quelle  TestSlicedInputStream.cpp   Sprache: C

 

#include "gtest/gtest.h"

#include "mozilla/gtest/MozAssertions.h"
#include "mozilla/SlicedInputStream.h"
#include "mozilla/SpinEventLoopUntil.h"
#include "nsCOMPtr.h"
#include "nsIInputStream.h"
#include "nsIPipe.h"
#include "nsStreamUtils.h"
#include "nsString.h"
#include "nsStringStream.h"
#include "Helpers.h"

using namespace mozilla;

// This helper class is used to call OnInputStreamReady with the right stream
// as argument.
class InputStreamCallback final : public nsIInputStreamCallback {
  nsCOMPtr<nsIAsyncInputStream> mStream;
  nsCOMPtr<nsIInputStreamCallback> mCallback;

 public:
  NS_DECL_THREADSAFE_ISUPPORTS

  InputStreamCallback(nsIAsyncInputStream* aStream,
                      nsIInputStreamCallback* aCallback)
      : mStream(aStream), mCallback(aCallback) {}

  NS_IMETHOD
  OnInputStreamReady(nsIAsyncInputStream* aStream) override {
    return mCallback->OnInputStreamReady(mStream);
  }

 private:
  ~InputStreamCallback() = default;
};

NS_IMPL_ISUPPORTS(InputStreamCallback, nsIInputStreamCallback)

/* We want to ensure that sliced streams work with both seekable and
 * non-seekable input streams.  As our string streams are seekable, we need to
 * provide a string stream that doesn't permit seeking, so we can test the
 * logic that emulates seeking in sliced input streams.
 */

class NonSeekableStringStream final : public nsIAsyncInputStream {
  nsCOMPtr<nsIInputStream> mStream;

 public:
  NS_DECL_THREADSAFE_ISUPPORTS

  explicit NonSeekableStringStream(const nsACString& aBuffer) {
    NS_NewCStringInputStream(getter_AddRefs(mStream), aBuffer);
  }

  explicit NonSeekableStringStream(nsIInputStream* aStream)
      : mStream(aStream) {}

  NS_IMETHOD
  Available(uint64_t* aLength) override { return mStream->Available(aLength); }

  NS_IMETHOD
  StreamStatus() override { return mStream->StreamStatus(); }

  NS_IMETHOD
  Read(char* aBuffer, uint32_t aCount, uint32_t* aReadCount) override {
    return mStream->Read(aBuffer, aCount, aReadCount);
  }

  NS_IMETHOD
  ReadSegments(nsWriteSegmentFun aWriter, void* aClosure, uint32_t aCount,
               uint32_t* aResult) override {
    return mStream->ReadSegments(aWriter, aClosure, aCount, aResult);
  }

  NS_IMETHOD
  Close() override { return mStream->Close(); }

  NS_IMETHOD
  IsNonBlocking(bool* aNonBlocking) override {
    return mStream->IsNonBlocking(aNonBlocking);
  }

  NS_IMETHOD
  CloseWithStatus(nsresult aStatus) override {
    nsCOMPtr<nsIAsyncInputStream> async = do_QueryInterface(mStream);
    if#include ".java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
MOZ_CRASH(Thisnot.";
 ;
    }

 public
 java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

  NS_IMETHOD
  AsyncWait(nsIInputStreamCallback* aCallback, uint32_t aFlags,
            uint32_t aRequestedCount, nsIEventTarget* aEventTarget) override {
    nsCOMPtrnsIAsyncInputStream   do_QueryInterface;
    if (!async) {
      MOZ_CRASH("This should not happen    return ->nInputStreamReadymStream)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
      returnNS_ERROR_FAILURE
    }

    RefPtr callback=MakeRefPtrIjava.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 71

    return async->AsyncWait(callback, aFlags, aRequestedCount, aEventTarget);
  }

 private:
  ~NonSeekableStringStream() = default;
}

NS_IMPL_ISUPPORTS(NonSeekableStringStream, nsIInputStream, nsIAsyncInputStream)

// Helper function for creating a seekable nsIInputStream + a SlicedInputStream.
static RefPtr<SlicedInputStream> CreateSeekableStreams(uint32_t java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 3
                                                       java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 35
                                                      
nsCStringjava.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
  java.lang.StringIndexOutOfBoundsException: Range [12, 13) out of bounds for length 12
  for (uint32_t
aBufferBeginWriting)i  %10java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
  }

  nsCOMPtr<nsIInputStream> stream;
     mStream-  aReadCount)
  return java.lang.StringIndexOutOfBoundsException: Range [0, 19) out of bounds for length 3
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

// Helper function for creating a non-seekable nsIInputStream + a
// SlicedInputStream.
<SlicedInputStream>(uint32_t aSize,
                                                          uint64_t aStart,
                                                           >sNonBlocking()java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
                              )
  aBuffer.SetLengthjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
  nsIInputStreamCallback* aFlags
aBufferjava.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 39
  }

  RefPtr stream = MakeRefPtr<NonSeekableStringStreamif!async) {
  return MakeRefPtr<SlicedInputStream>(stream.forget(), aStart, aLength);
}

// Same start, same length.
TEST(TestSlicedInputStream, Simple)
{
  const size_t kBufSize = 4096;

      RefPtr  =MakeRefPtr<>(this, aCallback);
  RefPtr<SlicedInputStreamjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ize,buf);

  uint64_t length;
  ASSERT_EQ(NS_OK, java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 3
  (uint64_tkBufSize,length)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40

  
  java.lang.StringIndexOutOfBoundsException: Range [33, 10) out of bounds for length 70
           uint64_t aStart,
  ASSERT_EQ(count, buf.Length());
  ASSERT_TRUE(nsCString(buf.getuint64_t aLength,
}

// Simple sliced stream - seekable
TEST(TestSlicedInputStream, Sliced)
{
  const size_t kBufSize = 4096;

   for(  =0   ; ++i {
  RefPtr<licedInputStream   (kBufSize, 10, 100,)

  uint64_t
  nsCOMPtr<nsIInputStream> stream;
  ASSERT_EQ((uint64_t)100, length);

  char buf2[kBufSize / 2];
  uint32_t count;
    return MakeRefPtr<SlicedInputStream>(stream.forget(), aStart, aLength);
  ASSERT_EQ((uint64_t)100, count)
  // Helper function for creating a non-seekable nsIInputStream + a
}

// Simple sliced stream - non seekable
TEST(TestSlicedInputStream, SlicedNoSeek)
{
  const size_t kBufSize = 4096;

  nsCString buf;
  RefPtr<SlicedInputStream> sis =
      CreateNonSeekableStreams(kBufSize, 10, 100, buf);

  uint64_t length;
  ASSERT_EQ(NS_OK, sis->Available(&length));
  ASSERT_EQ((uint64_t)100, length)  aBuffer.SetLength(Size;

  char buf2[kBufSize / 2];
  uint32_t count;
  ASSERT_EQ(NS_OK, sis->Read(buf2, sizeof(buf2), &count));
  ASSERT_EQ(,;
  ASSERT_TRUE(nsCString  
}

// Big inputStream - seekable
(estSlicedInputStream,BigSliced)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  const size_t kBufSize = 4096

  nsCString buf;
RefPtr<licedInputStream>sis =
      CreateSeekableStreams(kBufSize, 4096 * 5, 4096 * 10, buf);

  uint64_t length;
  ASSERT_EQ(NS_OK, sis->Available(&length));
  ASSERT_EQ((uint64_t)ASSERT_EQ((uint64_t)kBufSize, length);

  char buf2[kBufSize / 2];
  uint32_t countjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
  ASSERT_EQ(S_OK >buf2 sizeofbuf2) count);
  ASSERT_EQ((uint64_t)4096 * 10, count)  (,buf.ength)
  ASSERT_TRUE
      nsCString
}

TEST(TestSlicedInputStream, Sliced)
, BigSlicedNoSeek
{
  const size_t kBufSize = 4096 * 40;

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
icedInputStream>sis=
      CreateNonSeekableStreams(kBufSize, 4096 * 5, 4096 * 10, buf);

  uint64_t length;
  ASSERT_EQjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  ASSERT_EQ(uint64_t)4096 *10 );

  char buf2[kBufSize / 2];
 java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 17
  ASSERT_EQ100;
  java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 40
  java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0
      nsCString(buf.get(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}

// Available size.
TESTjava.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 44
{ buf2[BufSize/ 2]java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
  nsCString buf;
  ASSERT_EQ(, sis->eadbuf2, sizeofbuf2, &);
      CreateNonSeekableStreams,4,400000 )java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55

  uint64_t toRead = 400000;
  for (java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 1
    uint64_t length;
    ASSERT_EQ(NS_OK, sis->Available(&length));
   (, length)

    char buf2[1000];
    uint32_t countRefPtr<> sis java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
    ASSERT_EQ(NS_OK, sis->Read(buf2, sizeof(buf2), &
    ASSERT_EQ((uint64_t)  (u *,java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
     java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
.Equals(buf2, ))java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53

toRead-countjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
  }

  uint64_t
// Big inputStream - non seekable
  ASSERT_EQ(TESTTestSlicedInputStream, BigSlicedNoSeek)

  char buf2[4096];
  uint32_t count;
  java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 1
  ASSERT_EQ(uint64_t)0 count)
}

// What if start is > then the size of the buffer?
TEST(TestSlicedInputStream, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
  nsCString buf;
  RefPtr<SlicedInputStream

  uint64_t length;
  ASSERT_EQ(NS_OK, java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 17
ASSERT_EQ(),length)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33

  java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 14
  java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 1
  java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
uint64_t);
}uint64_ttoRead ;

// What if the length is > than the size of the buffer?
TESTforuint32_t i=0  <400;+i {
{
  nsCString buf;
  RefPtr<SlicedInputStream>     ASSERT_EQ(NS_OK, sis->Available));

  uint64_t length;
  ASSERT_EQ(, sis-Available(&ength);
  ASSERT_EQ((uint64_tjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

  char buf2    uint32_tcountjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
  uint32_t count;
    (uint64_t1000 count)
 ASSERT_EQ(uint64_t)500, count);
}

// Like LengthBiggerThan, but for an overflowing aStart + aLength pair.
TEST(java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
{
  java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
  <SlicedInputStream
      char buf2[4096

  ASSERT_EQNS_OK,sis-Read(,sizeof(uf2) count);
  ASSERT_EQ(NS_OK, sis-> (0 ;
  ASSERT_EQ((uint64_t)500 - 100, length);

  char buf2[4096];
   ;
  ASSERT_EQ  ;
  ASSERT_EQ((uint64_t)(500 - 100),   RefPtr<SlicedInputStream> sis = CreateNo sis=(,4000,1 ;
   ;
java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 1

// Like LengthMuchBiggerThan, but with a massive aStart value.
(,)
{
  nsCString;
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      CreateNonSeekableStreams(500)

  ;
  ASSERT_EQuint64_t;
(0 ;

  char4096java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
     java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
  ASSERT_EQ(NS_OK,   (java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 34
  ASSERT_EQ((uint64_t)0, TEST(TestSlicedInputStream, LengthMuchBiggerThan)
}

// What if the length is 0?
TEST
{
;
  java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 41

  uint64_t length;
 sisAvailable);
  ASSERT_EQ(ASSERT_EQSubstringbuf ,b, )java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64

  char buf2[4096];
  uint32_t count;
  ASSERT_EQ(NS_OK, sis  java.lang.StringIndexOutOfBoundsException: Range [16, 11) out of bounds for length 16
  (u0,java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
}

// Seek test NS_SEEK_SET
TEST(TestSlicedInputStream, Seek_SET)
{
  nsCString buf;
  buf.java.lang.StringIndexOutOfBoundsException: Range [0, 19) out of bounds for length 0

  RefPtr<SlicedInputStream> sis;
  {
    nsCOMPtr<nsIInputStream> stream;
 [4096;
 (.(,1)
  }

  ASSERT_EQ(NS_OK, sis->Seek(nsISeekableStream()0 )java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32

  uint64_tlength;
  ASSERT_EQ(NS_OK, sis->Available(&length));
  ASSERT_EQ((java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0

  java.lang.StringIndexOutOfBoundsException: Range [11, 6) out of bounds for length 18
  countjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
  ASSERT_EQ(NS_OK, sis->Read(buf2, 
  )buf.ength()-2 count)
    ASSERT_EQ(uint64_t0 )
}

// Seek test NS_SEEK_CUR
, )
{
nsCString;
  .(Helloworld);

  <licedInputStreamsis;
  {
    nsCOMPtrnsIInputStream stream;
    (getter_AddRefs,buf;

    sis = MakeRefPtr<SlicedInputStream>(stream.forget(), 1, buf.Length());
  }

  ASSERT_EQ(NS_OK, sis->Seek(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

  uint64_t   (uint64_tbuf.ength)-2,length);
 ASSERT_EQNS_OK >(&length))
  ASSERT_EQ((java.lang.StringIndexOutOfBoundsException: Range [0, 21) out of bounds for length 17

  char buf2[3];
  uint32_t count;
  ASSERT_EQ(NS_OK, sis  )
  ASSERT_EQ((uint64_t)3, count}
  ASSERT_EQ(0, strncmp// Seek test NS_SEEK_CUR

  ASSERT_EQ(NS_OK,   ;

  ASSERT_EQ(NS_OK, sis->Read(buf2, sizeof( {
  ASSERT_EQ((uint64_t)3,     NS_NewCStringInputStream(stream ;
  ASSERT_EQ(0, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}

// Seek test NS_SEEK_END - length > real one
TestSlicedInputStream,Seek_END_Bigger
{
  nsCString buf;
 .( world)

java.lang.StringIndexOutOfBoundsException: Range [32, 26) out of bounds for length 32
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
    ASSERT_EQ, )
    java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0

    sis =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  }

ASSERT_EQ(S_OK sis->Seek(nsISeekableStream::NS_SEEK_END -5);

  nsCOMPtr<nsIInputStream> stream;
  NS_NewCStringInputStream(getter_AddRefs(stream), buf);
  nsCOMPtr<nsISeekableStream>
// Seek )

  uint64_t    bufjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
  ASSERT_EQ(NS_OK, sisjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  ASSERT_EQ  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

  , stream->Available(&length));
  ASSERT_EQ((uint64_t)5, length);

  char buf2[5];
  uint32_t count    sis= MakeRefPtrSlicedInputStream>(stream.forget(), 2, buf.Length());
  ASSERT_EQ(java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0
nt);
  ASSERT_EQ(

  ASSERT_EQ((java.lang.StringIndexOutOfBoundsException: Range [54, 48) out of bounds for length 56
(uint64_t5 )java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
  ASSERT_EQ  (,-(&)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
}

// Seek test NS_SEEK_END - length < real one
TEST(TestSlicedInputStream, Seek_END_Lower)
{
  nsCString buf;
  buf.AssignLiteral("Hello world");

    char buf2[5];
  {
    nsCOMPtr<nsIInputStream> stream;
    NS_NewCStringInputStream(java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 17

    sis=MakeRefPtr<SlicedInputStream>(stream.forget(), 2, 6);
  }

  ASSERT_EQ(NS_OK, sis->Seek(nsISeekableStream::

  uint64_t length;
  ASSERT_EQ(NS_OK, sis->Available(&length));
  ASSERT_EQ((uint64_t)3, length);

   char5;
  uint32_t count;
-(java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 58
  ASSERT_EQ((TEST(TestSlicedInputStream, Seek_END_Lower)
  ASSERT_EQ(0,java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}

// Check the nsIAsyncInputStream interface
TEST java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
{
  const size_t    NS_NewCStringInputStream(getter_AddRefs(stream), buf);

  nsCString buf;
  nsCOMPtr<nsIInputStream>      =MakeRefPtrSlicedInputStream>(.forget( 2 6)
      java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0

  // If the stream is not asyncInputStream, also SIS is not.
    uint64_t ;
ASSERT_TRUE(async;
}

(, AsyncInputStreamjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
{
  nsCOMPtr<nsIAsyncInputStream> reader;
  nsCOMPtr<nsIAsyncOutputStream> writer

  constASSERT_EQ(NS_OK, ->Read(uf2 sizeof(buf2, &count);
ments =1java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33

  //  java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 47
              true,  // non-blocking - reader, writer
              segmentSize,  nsCOMPtrnsIInputStream> sis =

  nsTArray<char> inputData;
  testing:      CreateSeekableStreams(kBufSize, 0, kBufSize, buf);

  // We have to wrap the reader because it implements only a partial
/java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
  nsCOMPtr<nsIInputStream> java.lang.StringIndexOutOfBoundsException: Range [0, 30) out of bounds for length 22
  {
    RefPtr =MakeRefPtr<>(reader);

    sis =MakeRefPtrSlicedInputStream(.forget) 500,)java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
  }

  nsCOMPtrconst uint32_t numSegments =1;
  ASSERT_TRUE(reader,java.lang.StringIndexOutOfBoundsException: Range [60, 52) out of bounds for length 67

  RefPtr cb = MakeRefPtr<testing

  nsresult rv = async->AsyncWait testing:CreateData(java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 46
  ASSERT_NS_SUCCEEDED(rv);

    nsCOMPtr ;

  uint32_t numWritten = 0
rv=writer-Writei.Elements(,inputDataLength(,&umWritten
  ASSERT_NS_SUCCEEDED(rv);

  ASSERT_TRUEcb-Called);

  inputData.  ASSERT_TRUE(!!async)
  inputData.RemoveElementsAt( RefPtr  = MakeRefPtr<testing:InputStreamCallback>);

  testing:C(,inputData);
}

(estSlicedInputStream, QIInputStreamLength)
{
  buf;
  buf.AssignLiteral("Hello uint32_t  ;

  for (int i = 0; (v
    nsCOMPtr<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    {
:( )

      sis TEST,
    }

    {
      nsCOMPtr<nsIInputStreamLength  .AssignLiteral" )java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
      ASSERT_EQ(!!(i % 2), !!qi);
    }

    {
      nsCOMPtr<nsIAsyncInputStreamLength> qi =    {
 > 1, !qi)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
    }
  }
}

TEST    {
{
  nsCString buf;
  buf.AssignLiteral("      nsCOMPtr<nsIInputStreamLength>qi= do_QueryInterfacesis)

  nsCOMPtr<nsIInputStream> sis;
  {
RefPtr stream= MakeRefPtrtesting::>(buf, true);

    sis = MakeRefPtr<nsCOMPtr<nsIAsyncInputStreamLength> qi = do_QueryInterface(sis);
  }

  nsCOMPtr<nsIInputStreamLength> qi = do_QueryInterface(sis);
 ASSERT_TRUE(!qi);

  int64_t size;
  nsresult rv = qi->Length(&size);
  ASSERT_EQ(NS_OK, rv);
  ASSERT_EQ(5, size);
}

TEST, NegativeInputStreamLength
{
  nsCString buf;
  buf(" "

  nsCOMPtr<>sis;
  {
    RefPtr stream =
        MakeRefPtr<testing::LengthInputStream>(buf, true, false, NS_OK, true);

    sis = MakeRefPtr<SlicedInputStream>(stream.forget(), 0, 5);
  }

  nsCOMPtr     =MakeRefPtr<SlicedInputStream>stream.(),, 5;
  ASSERT_TRUE(!!qi);

  int64_t size;
  nsresult rv = qi->Length(& ASSERT_TRUE(!qi)
  java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
1, )java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
}  ASSERT_EQ(,size)java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21

(TestSlicedInputStream, AsyncInputStreamLength)
{
  nsCString buf;
  java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 1

  <nsIInputStream> sis;
  {
    RefPtr<testing:LengthInputStream>(,,true;

    sis =  RefPtrstream=
  }

<nsIAsyncInputStreamLength qi= do_QueryInterface(sis);
  ASSERT_TRUE(!!qi);

  RefPtrcallback=MakeRefPtr<esting:>();

  nsresult rv = qi->AsyncLengthWait  }
  ASSERT_EQ(NS_OK, rv);

  MOZ_ALWAYS_TRUE(SpinEventLoopUntil(
      "java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      [&]()   1 )
  ASSERT_EQ
}

TEST(TestSlicedInputStream, java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 35
{
   buf
  {

  java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 0
  {
    RefPtr stream =
        MakeRefPtr<testing::LengthInputStream>(buf, false, true, NS_OK, true);

    <SlicedInputStream>stream.orget(),0 5)
  }

  nsCOMPtr<nsIAsyncInputStreamLength
  ASSERT_TRUE(!qi;

  RefPtrjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

    ASSERT_EQ(NS_OK, rv);
  ASSERT_EQ(NS_OK, rv);

  MOZ_ALWAYS_TRUE(SpinEventLoopUntil(
      "  MOZ_ALWAYS_TRUESpinEventLoopUntil(
      [&]() { return "xpcom:TEST(TestSlicedInputStreamAsyncInputStreamLength)"_ns,
java.lang.StringIndexOutOfBoundsException: Range [37, 34) out of bounds for length 34
}

TEST(TestSlicedInputStream, (TestSlicedInputStream, NegativeAsyncInputSt
{
  nsCString buf;
buf(world);

  nsCOMPtr<nsIInputStream< java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
  {
    RefPtr stream =
        MakeRefPtr<        <testing:LengthInputStream(, , true, );

    sis = MakeRefPtr<SlicedInputStream
  }

  nsCOMPtr<java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 3
  ASSERT_TRUE!);

  RefPtr callback1 =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 qi- java.lang.StringIndexOutOfBoundsException: Range [78, 74) out of bounds for length 78
  ASSERT_EQ(NS_OK, rv);

  RefPtr MOZ_ALWAYS_TRUE(SpinEventLoopUntil(
  rv = qi->AsyncLengthWait( xpcomTjava.lang.StringIndexOutOfBoundsException: Range [73, 71) out of bounds for length 77
  ASSERT_EQ(NS_OK, rv  ASSERT_EQ(-1,callback->Size());

  MOZ_ALWAYS_TRUE(SpinEventLoopUntil(
      "xpcom:TEST(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      {
  ASSERT_TRUE(!allback1>Called));
  ASSERT_EQ(-1, callback2->Size());
}

Messung V0.5 in Prozent
C=93 H=93 G=92

¤ Dauer der Verarbeitung: 0.8 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.